Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 form like statements

Status
Not open for further replies.

maverickmonster

Programmer
May 25, 2004
194
GB
Hi all

I have three types of input boxes in my form either a alpha numeric, number or date.

If I enter the wrong type in to the wrong box, i get a error msg and the program crashes, how can i safe guard against these three eventualitys. I was thinking about using a like statement as i have breifly used one before.

Thanks

MM
 
Look for the Validate event in VBHelp, Also check out the IsNumeric and IsDate functions. You may also consider using a DateTimePicker control as a fairly reliable way of inputting dates.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
maverickmonster,

As John has said IsNumeric is good for checking for numbers. 'Like' can be useful but only if you want to restrict entry to a certain pattern/ format of numbers.

eg.

If Not (Text1 Like "####") Then
MsgBox "Entry must consist of 4 numbers"
End If

regards Hugh


 
You can also look into the MS masked edit box. Control needs to be added to your tool box.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top