|
-
May 28th, 2002, 09:01 PM
#1
Thread Starter
Addicted Member
Simple question
Ok if i have a text box and only want the input of number and letter, what do i do to set it to that?
-
May 28th, 2002, 09:13 PM
#2
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not(LCase$(Chr$(KeyAscii)) Like "[a-z]") And Not(Chr$(KeyAscii) Like "[0-9]") Then
KeyAscii = 0
End If
End Sub
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
May 28th, 2002, 09:15 PM
#3
Frenzied Member
What if you're evil like me and you like pasting in wierd symbols just to screw up programs?
You just proved that sig advertisements work.
-
May 28th, 2002, 09:16 PM
#4
In the Keypress event check the ASCII code. I'm not sure what you want to do but this gives you an idea:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii > 47 And KeyAscii < 58) Or _
(KeyAscii > 64 And KeyAscii < 91) Or _
(KeyAscii > 96 And Keascii < 123) Then
' ascii code is okay
Exit Sub
End If
MsgBox "You entered an invalid character", vbOKOnly
End Sub
-
May 28th, 2002, 09:23 PM
#5
Originally posted by nishantp
What if you're evil like me and you like pasting in wierd symbols just to screw up programs?
Then consider yourself amongst the hacker elite.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
May 28th, 2002, 09:25 PM
#6
Thread Starter
Addicted Member
Hmm that guys, but i used crptcblade code, and it work, only is i can't backspace anything.
-
May 28th, 2002, 09:29 PM
#7
Just add the backspace condition in
VB Code:
If Not(LCase$(Chr$(KeyAscii)) Like "[a-z]") And Not(Chr$(KeyAscii) Like "[0-9]")[b] And (KeyAscii <> vbKeyBack)[/b] Then
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
May 28th, 2002, 09:34 PM
#8
Thread Starter
Addicted Member
Ok thanks, also I have a splah screen, how do i make that start up first?
-
May 28th, 2002, 10:19 PM
#9
VB Code:
Private Sub [SpashScreen]_Load()
'Start timer.
Timer1.Interval = 2000 ‘2 Seconds
End Sub
Private Sub Timer1_Timer()
'Disable the timer and show the frmMain form
Timer1.Enabled = False
frmMain.Show
Unload Me
End Sub
Private Sub [SplashScreen]_dblClick()
‘Gives the user a method to close off the SpashScreen
frmMain.Show
Unload Me
End Sub
-
May 28th, 2002, 10:29 PM
#10
The picture isn't missing
or if it isnt because you want to do background stuff while it is loading jst go to Project>(project name) Properties> and choose startup object be your splash screen form.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
May 28th, 2002, 10:39 PM
#11
Originally posted by nishantp
What if you're evil like me and you like pasting in wierd symbols just to screw up programs?
Well then............. u could do this:
VB Code:
Option Explicit
Private Sub Text1_Validate(Cancel As Boolean)
Dim sBuff As String
Dim s As String
Dim i As Integer
For i = 1 To Len(Text1.Text)
s = Mid$(Text1.Text, i, 1)
If s Like "[a-z]" Or s Like "[A-Z]" Or s Like "[0-9]" Then sBuff = sBuff & s
Next
Text1.Text = sBuff 'Or
'myVariable = sBuff
End Sub
To trap evil, weird syboled people.......
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
|