Hi Gerry,
Here is a simple demo for you. You may need to realize your own algorithm
to validate user's input. You may create a new VB.NET windows project and
add two textboxes and a button on to the form. Here is the code of
Button1_Click.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim str As String = TextBox1.Text
Dim dt As DateTime
dt = Now
Dim str1, str2, str3 As String
If str.Length = 6 Then
str1 = str.Substring(0, 2)
str2 = str.Substring(2, 2)
ElseIf str.Length = 5 Then
str1 = str.Substring(0, 1)
str2 = str.Substring(1, 2)
End If
str3 = str.Substring(str.Length - 2, 2)
' Mod is a operation, for example, 13 mod 12 = 1, 24
mod 12 =0 and so.
Dim ddt As New System.DateTime(dt.Year, dt.Month, dt.Day,
CInt(str1) Mod 12, CInt(str2) Mod 60, dt.Second)
TextBox2.Text = ddt.ToString() + UCase(str3)
End Sub
Please try the code above and let me know if this is what you want!
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure!
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Gerry Viator" <viatorg@musc.edu>
References: <#$m#ZlOYDHA.1680@tk2msftngp13.phx.gbl>
<0a9901c360ef$ee469840$a001280a@phx.gbl>
Subject: Re: Todays date plus Time that is typed
Date: Tue, 12 Aug 2003 13:19:47 -0400
Lines: 62
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ubDKwXPYDHA.3924@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: viatorg.gi.musc.edu 128.23.252.142
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:104327
X-Tomcat-NG: microsoft.public.dotnet.general
Thanks for your help,
The number is adding. I'm sorry for not being clear.
I want to replace the minutes with the time corsponding to the 4 or 3
numbers.
like if the current time is 8/12/2003 1:02:48 PM
and the user typed in this 325PM would change to 8/12/2003 3:25:00 PM
the user will be able to type in either 3 or 4 numbers and ending in