Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Way to only allow numbers in a text box?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
cildor666
Advanced Cheater
Reputation: 0

Joined: 08 Mar 2008
Posts: 95

PostPosted: Wed Sep 24, 2008 10:31 am    Post subject: Way to only allow numbers in a text box? Reply with quote

I'm using Visual Basic 2008 Express.

Is there a way to only allow numbers in a text box, so if i click a button it pops up saying 'Not numeric!" when there is text typed into the box.

Thanks for any help.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Sep 24, 2008 11:15 am    Post subject: Reply with quote

you can start a timer / thread and set it to 1 (ms) and check if one of the chars in the text field isn't numberic
_________________
Stylo
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Wed Sep 24, 2008 11:29 am    Post subject: Reply with quote

1qaz wrote:
you can start a timer / thread and set it to 1 (ms) and check if one of the chars in the text field isn't numberic
Or, put a the check in the TextChanged event.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Sep 24, 2008 11:44 am    Post subject: Reply with quote

HolyBlah wrote:
1qaz wrote:
you can start a timer / thread and set it to 1 (ms) and check if one of the chars in the text field isn't numberic
Or, put a the check in the TextChanged event.

much better Cool

_________________
Stylo
Back to top
View user's profile Send private message
cildor666
Advanced Cheater
Reputation: 0

Joined: 08 Mar 2008
Posts: 95

PostPosted: Wed Sep 24, 2008 12:06 pm    Post subject: Reply with quote

Thanks for the help guys but i figured out a different way.

Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

    Dim allowedChars As String = "0123456789"

    If allowedChars.IndexOf(e.KeyChar) = -1 Then
        MsgBox("Only numbers are allowed.", MsgBoxStyle.Information)
        e.Handled = True
    End If


Is there any way to allow backspace in the 'Dim allowedChars As String = "0123456789" ??
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Wed Sep 24, 2008 3:30 pm    Post subject: Reply with quote

Code:
Private Sub Text1_Change()
If IsNumeric(Text1.Text) = False Then

    MsgBox "Numbers only"
End If
End Sub

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites