×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Type checking in VB

Type checking in VB

Type checking in VB

(OP)
How do you type check in VB?

Suppose I have a Textbox which I want to accept only integers, and give error otherwise. Is there a built in function that lets you set the textbox data  type?

Thanks.

jevakil@mapdi.com

One nuclear bomb can ruin your whole day.

RE: Type checking in VB

You can use the isnumeric function similar to the following example

If isnumeric(textbox.text) then

'action if numeric

Else

msgbox "Must enter a numeric value"
textbox.setfocus

End If

I hope this helps you out

RE: Type checking in VB

I normally use something like:

Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 46, 48 To 57  'backspace, dec point & numbers only
Exit Sub
Case Else
    KeyAscii = 0
    Beep
End Select
End Sub

You still need to stop cut&paste though

Good Luck
johnwm

RE: Type checking in VB

(OP)
Thank you very much gentelment.

Regards,

Javad

jevakil@mapdi.com

One nuclear bomb can ruin your whole day.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources