Click to See Complete Forum and Search --> : I got 2 probelms please help
XxEvilxX
Jan 11th, 2000, 10:32 AM
first probelm i want to take the first letter out of a textbox like say if the textbox.text = "Welcome" then i want A ="W"
and then i want the textbox to say "elcome"
second probelm
i want it where they can only type in 0 and 1
LG
Jan 11th, 2000, 11:05 AM
Hi,there.
Try this code:
Dim a As String
Dim b As String
a = "Welcome"
b = Mid(a, 2)
Text1 = b
It will return you "elcome". I didn't get what you want to do with "W"
Larisa
LG
Jan 11th, 2000, 11:28 AM
For your secont question code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > Asc("1") Or KeyAscii < Asc("0") Then
KeyAscii = 0 'block the letters
Exit Sub
End If
End Sub
And if you want to display only one number , than you have to set MaxLength property to 1.
But you going to run into one problem, you can delete number in a text box only by highligh and press delete. There probably should be additional code. I will try to play with that.
Larisa
LG
Jan 11th, 2000, 11:54 AM
OK. This is better:
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = IIf(KeyAscii = Asc("1") Or KeyAscii = Asc("0") Or KeyAscii = vbKeyBack, KeyAscii, 0)
End Sub
Larisa
XxEvilxX
Jan 11th, 2000, 11:58 AM
lg no see i dont want to also get rid of the w i want to keep it as b and have text1.text be elcome and have b = w do you see
LG
Jan 11th, 2000, 12:19 PM
I don't think I got it. Do you want something like that:
Dim a As String
Dim b As String
Dim s As String
a = "welcome"
b = Mid(a, 2)
Text1 = b
c = Mid(a, 1, 1)
Text2 = c
b will return you "elcome"
c will return you "w"
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.