|
-
Dec 1st, 2001, 08:45 AM
#1
Thread Starter
New Member
vb for Excel 2k
I have created a userform containing a button and a solitary textbox. I want users to enter a 4-digit number in the text box and then click the button. My problem is validating the text box so that it only accepts numeric values. If any one can help I would be grateful.
-
Dec 1st, 2001, 09:03 AM
#2
Lively Member
Are you using Excel as your Database or ms access?
-
Dec 1st, 2001, 09:35 AM
#3
Conquistador
lol, clueless
VB Code:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
Else
KeyAscii = 0
End If
End Sub
-
Dec 1st, 2001, 09:46 AM
#4
Lively Member
WHAT......3,668 post later.....
I only wonder how good you were in the begining!
-
Dec 1st, 2001, 10:01 AM
#5
Conquistador
heheheh
when i was 13 i wasn't all that bad, i was just starting to pick it up
i'm 15 know and i'm confident with VB 
it just takes a bit of time
-
Dec 1st, 2001, 10:06 AM
#6
Lively Member
Well you seem very good.....
I only wish I had started sooner......
-
Dec 1st, 2001, 10:08 AM
#7
Conquistador
thanks
why, how old are you (if you don't mind me asking )?
-
Dec 1st, 2001, 10:11 AM
#8
Lively Member
I'm 24 and will be 25 in a couple of weeks....(Over the hill)
-
Dec 1st, 2001, 10:15 AM
#9
Conquistador
heheheh
you're really old 
j/k
-
Dec 1st, 2001, 10:20 AM
#10
Lively Member
I missed a question: Why? Better understanding, better pay....it would have given me the opportunity to learn other things computer related
PS
I was taken by the age question...I haven't really wanted to celebrate my birthday since I was 22
-
Dec 1st, 2001, 10:36 AM
#11
Lively Member
I'm SURE you will do well.......you might even succeed in making some VB professors double check their knowledge on the subject once you get in college...(This makes them very uncomfortable, I've seen it happen....its kindve of funny)
I was hoping that maybe you could help me with a question I posted earlier on the forum.
How much do you know about Data environment?
I have a "Beginners Question", so dont laugh!!!!!!
I want to open connection1 through programming code so that I can use app.path, however it looks like you can only set the connection by right clicking and going down to properties(to establish the connection) and then later adding the command
-
Dec 1st, 2001, 12:59 PM
#12
Thread Starter
New Member
i'm new to vb and currently i have this on my button
Private Sub BtnAccept_Click()
If Len(TextBox1) Or Len(TextBox2) Or Len(TextBox3) Or Len(TextBox4) < 4 Then
CreditCardDetails.Hide
CreditCardDetails.Show
Else
answer = MsgBox("Do You Wish To Proceed", vbYesNo, "Warning")
If answer = vbYes Then
CreditCardDetails.Hide
Application.Run "'GOL User.xls'!AddOrderToList"
Thankyou.Show
Else
CreditCardDetails.Hide
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
End If
End If
End Sub
how would I encorporate that previous bit of code into this to check all four textboxes
-
Dec 1st, 2001, 05:22 PM
#13
Conquistador
in VBA
just put that code in the keypress events of each text box
or in vb use, this:
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = CheckIt(KeyAscii)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
KeyAscii = CheckIt(KeyAscii)
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
KeyAscii = CheckIt(KeyAscii)
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
KeyAscii = CheckIt(KeyAscii)
End Sub
Function CheckIt(KeyAscii As Integer) As Integer
If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
CheckIt = KeyAscii
Else
CheckIt = 0
End If
End Function
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
|