|
-
Sep 25th, 2000, 07:56 AM
#1
Thread Starter
New Member
How can I set the textbox to accept something of a given format like 'HH:mm' (12:22).
I belive that some API could solve it, but I can't find out how to do it.
TIA
Svein
-
Sep 25th, 2000, 10:14 AM
#2
Fanatic Member
I haven't tested it, but I think this code will work:
Code:
If Format(Text1,"hh mm")=Text1 Then
Msgbox "Ok"
Else
Msgbox "Wrong"
End If
-
Sep 25th, 2000, 02:24 PM
#3
So basically you want 4 numbers separated by a colon in the middle? If so, the Like operator would do the same.
Code:
If Text1 Like "##:##" Then MsgBox "Format is correct"
-
Sep 25th, 2000, 04:11 PM
#4
Thread Starter
New Member
Format in textbox
I believe that you misunderstand me.
What I'm looking for is a API call to set the textbox to accept a given format of input. Something like setting the textbox to accept only numeric or letters except that I now would like it to accept hours with to digits and minutes with two digits. hours and minutes should be separated by a ':'..
TIA
Svein
-
Sep 25th, 2000, 04:36 PM
#5
Use a MaskedEdit Control for this.
-
Sep 25th, 2000, 04:43 PM
#6
Or if you want to use a standard TextBox, use the following. Make sure to set the TextBox's MaxLength to 5 (4 numbers + colon).
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "#" Or KeyAscii = 8 Then
If Not KeyAscii = 8 Then If Len(Text1) = 2 Then Text1 = Text1 & ":"
Text1.SelStart = Len(Text1)
Else
KeyAscii = 0
End If
End Sub
-
Sep 26th, 2000, 06:51 AM
#7
Thread Starter
New Member
I guess that I have not been clear enough when posting earlier.
I have a ComboBox and in the editfield of this Combo I would like to have the format of Short Time.
I know that I can use the masked Edit instead of EditBox, but I dont wanna mess the form up by using av Masked Edit in this case.
Do anyone know of some codesnippet that makes up the Masked Edit control ?? Would there be possible to transform this code to function in the combobox ???
TIA
Svein A. Vårdal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|