Results 1 to 13 of 13
  1. #1
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy

    Help, Only numbers, no letters

    Hi!

    I need to make a textbox only accept numbers! No letters or special symbols!

    //H
    -Rest in peace leechers-

    Your PM box is 100% full.

  2. #2
    Calebb's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Posts
    212
    Reputation
    12
    Thanks
    75
    masked textbox?

  3. #3
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Code:
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    
        Dim NumbersAccepted As String = "0123456789" 'or the numbers you want to use
    
        If NumbersAccepted.IndexOf(e.KeyChar) = -1 Then
            e.Handled = True
        End If

  4. #4
    mnpeep's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    220
    Reputation
    12
    Thanks
    10
    My Mood
    Amazed
    Quote Originally Posted by lolland View Post
    Code:
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    
        Dim NumbersAccepted As String = "0123456789" 'or the numbers you want to use
    
        If NumbersAccepted.IndexOf(e.KeyChar) = -1 Then
            e.Handled = True
        End If
    DAM for a 12 year old your beast at VB

    PS you should make a multitool.

  5. #5
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    I would, but I prefer smaller projects.

  6. #6
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy
    Quote Originally Posted by lolland View Post
    Code:
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    
        Dim NumbersAccepted As String = "0123456789" 'or the numbers you want to use
    
        If NumbersAccepted.IndexOf(e.KeyChar) = -1 Then
            e.Handled = True
        End If
    Awsome thanks! It works only numbers and no letters! Thanks!

    But i can´t use backspace now :/ u know how to fix?
    -Rest in peace leechers-

    Your PM box is 100% full.

  7. #7
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Yeah, that's the only thing that sucks about that method. There's other better ways of doing it, I'll check my project folder (about 100 projects )

  8. #8
    Pixie's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pixie wird wieder steigen.
    Posts
    1,884
    Reputation
    22
    Thanks
    229
    My Mood
    Fine
    Quote Originally Posted by lolland View Post
    Yeah, that's the only thing that sucks about that method. There's other better ways of doing it, I'll check my project folder (about 100 projects )
    I think this may be why you can't backspace:
    Code:
    If NumbersAccepted.IndexOf(e.KeyChar) = -1 Then
            e.Handled = True
    I'm not sure, but you should probably look at it...
    I have another possible solution, but I don't feel like posting it right now
    Just PM me and I will answer it later (I'm too busy unpacking stuff from vacation)

  9. #9
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy
    Problem solved //Close

    Found a other way that worked much better Thans btw
    -Rest in peace leechers-

    Your PM box is 100% full.

  10. #10
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    What was it? I know I have it somewhere, but I've gone through 30 projects in like 2 hours and I don't wanna check the rest -.-

  11. #11
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Post the code, I know I have it but I cant find it :@

  12. #12
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy

    Smile VBVBVBVBVBVBVBVBVBVBVBVBVBVBVBVBVBVBVBVBVB

    Quote Originally Posted by lolland View Post
    Post the code, I know I have it but I cant find it :@
    Sure,

    Code:
     Private Function ValidateNumeric(ByVal strText As String) _
            As Boolean
            ValidateNumeric = CBool(strText = "" _
                Or strText = "-" _
                Or strText = "-." _
                Or strText = "." _
                Or IsNumeric(strText))
        End Function
    Code:
      If Not ValidateNumeric(TextBox1.Text) Then
    
    code here
    
    end if
    -Rest in peace leechers-

    Your PM box is 100% full.

  13. #13
    mnpeep's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    220
    Reputation
    12
    Thanks
    10
    My Mood
    Amazed
    cool code.

Similar Threads

  1. [Help]Random Number[Solved]
    By tremaster in forum Visual Basic Programming
    Replies: 5
    Last Post: 06-18-2010, 05:43 AM
  2. [Help]only one with this problem?
    By ZeroTroubles in forum Battlefield Bad Company 2 (BFBC2) Hacks
    Replies: 6
    Last Post: 04-13-2010, 11:11 AM
  3. [HELP] Only pros can help me :P PLEASE! :D
    By D e a t h h a u n t S in forum Visual Basic Programming
    Replies: 34
    Last Post: 11-23-2009, 03:13 PM
  4. help only if you know.
    By M2A in forum General
    Replies: 14
    Last Post: 11-12-2009, 09:28 PM
  5. HELP ME FIND KOREAN LETTERS
    By gnerex in forum WarRock Korea Hacks
    Replies: 2
    Last Post: 10-26-2008, 10:15 AM

Tags for this Thread