By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

Textbox in vb accepts only numbers

P: 36
Hai
My textbox accepts only positive numbers.It doesnot accept even floating points also.How to this?I wrote this code
//Code
Dim neg As Integer = 0
If (Not IsNumeric(envno.Text)) Or (envno.Text) <= neg Or Then
MsgBox("Please enter Positive numbers only.", vbInformation)
envno.Text = ""
envno.Focus()

My code accepts floating point numbers.How to do this?
Dec 19 '07 #1
Share this Question
Share on Google+
2 Replies


debasisdas
Expert 5K+
P: 8,127
You need to restrict "." character from user input.
Dec 19 '07 #2

jamesd0142
100+
P: 469
try something like this in your keypress:

Expand|Select|Wrap|Line Numbers
  1. if asc(e.keychar) <> "46" then
  2. 'allow
  3. 'code here
  4. end if
  5.  
Dec 19 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.