Results 1 to 11 of 11

Thread: Simple question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    143

    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?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     If Not(LCase$(Chr$(KeyAscii)) Like "[a-z]") And Not(Chr$(KeyAscii) Like "[0-9]") Then
    3.         KeyAscii = 0
    4.     End If
    5. End Sub

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    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.

  4. #4
    jim mcnamara
    Guest
    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

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    143
    Hmm that guys, but i used crptcblade code, and it work, only is i can't backspace anything.

  7. #7
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Just add the backspace condition in

    VB Code:
    1. 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

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    143
    Ok thanks, also I have a splah screen, how do i make that start up first?

  9. #9
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    VB Code:
    1. Private Sub [SpashScreen]_Load()
    2.     'Start timer.
    3.     Timer1.Interval = 2000    ‘2 Seconds
    4. End Sub
    5.  
    6. Private Sub Timer1_Timer()
    7.     'Disable the timer and show the frmMain form
    8.     Timer1.Enabled = False
    9.     frmMain.Show
    10.     Unload Me
    11. End Sub
    12.  
    13. Private Sub [SplashScreen]_dblClick()
    14.     ‘Gives the user a method to close off the SpashScreen
    15.     frmMain.Show
    16.     Unload Me
    17. End Sub

  10. #10
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    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 .

  11. #11
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    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:
    1. Option Explicit
    2.  
    3. Private Sub Text1_Validate(Cancel As Boolean)
    4.    Dim sBuff As String
    5.    Dim s As String
    6.    Dim i As Integer
    7.  
    8.    For i = 1 To Len(Text1.Text)
    9.       s = Mid$(Text1.Text, i, 1)
    10.       If s Like "[a-z]" Or s Like "[A-Z]" Or s Like "[0-9]" Then sBuff = sBuff & s
    11.    Next
    12.  
    13.    Text1.Text = sBuff 'Or
    14.    'myVariable = sBuff
    15.  
    16. 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
  •  



Click Here to Expand Forum to Full Width