|
-
Jan 11th, 2000, 11:32 AM
#1
Thread Starter
Addicted Member
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
-
Jan 11th, 2000, 12:05 PM
#2
Hyperactive Member
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
-
Jan 11th, 2000, 12:28 PM
#3
Hyperactive Member
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
-
Jan 11th, 2000, 12:54 PM
#4
Hyperactive Member
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
-
Jan 11th, 2000, 12:58 PM
#5
Thread Starter
Addicted Member
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
-
Jan 11th, 2000, 01:19 PM
#6
Hyperactive Member
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"
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
|