|
-
Sep 6th, 2000, 08:06 AM
#1
Thread Starter
Junior Member
How do I check a textbox for characters when it should only accept chars? Also I am having trouble formatting the text.
I would like to take the number entered and convert it to a percentage( 10 should look like this 10%) and one for time(1hr and 15min should look like this 1.15) Please help
-
Sep 6th, 2000, 08:26 AM
#2
Sorry if I hav understood this wrong, by "characters" do you mean text & not numbers?
If so you could do something like:
Code:
private sub command1_click()
If isnumeric(text1.text) then
MsgBox"please type letters only!"
End If
With the next part, you could use the format function...
format(text1.text, "##" & "%") or
Format(text1.text, "#.##")
Hope this helps!
Alex Read
-
Sep 6th, 2000, 09:44 AM
#3
Thread Starter
Junior Member
textbox
Hey Alex
the formatting isn't working, whenever I enter a number i t automatically multiplies it by 100(10 looks like 1000%) also I made a typo I am checking for text that should be numbers
-
Sep 6th, 2000, 09:49 AM
#4
Use If Not Isnumeric(text1.text) then...
And also:
Format(text1.text, "##")
text1.text = text1.text & "%"
Hope this helps!
-
Sep 6th, 2000, 10:09 AM
#5
Or you could capture the keys in the key press event:
To disable numbers any other characters,
Private Sub text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 65 To 90:
Case 97 to 122:
Case 8: 'backspace
Case Else
Beep
KeyAscii = 0
End Select
End Sub
-
Sep 6th, 2000, 02:34 PM
#6
Try the following:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Or KeyAscii = 32 Then Exit Sub
If Not Chr(KeyAscii) Like "[A-z]" Then KeyAscii = 0
End Sub
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
|