Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Networking>> Visual basic "Val function

Visual basic "Val function

Nigel Thomson
18-09-2002, 07:08 PM
hello people
The problem is this how do i use the val function in VB to throw up an error if the input variable is a letter instead of a number as it seems to convert it to its ascii equivalent.
In delphi the val function throws out an error message if the input variable is a letter instead of a number.
I am a student and the system here does not have the VB helpfiles so I can't find anything about the val function apart from the very basics.

thanks in advance

parry
18-09-2002, 07:53 PM
Hi Nigel, you will first need to do an if statement using IsNumric to see if its a number or not.

Example, with error produced and focus turned to invalid field

If IsNumeric(FieldName) = false then
msgbox "Must be numeric"
FieldName.SetFocus
exit sub
else val(FieldName)
end if

cheers
Parry

Nigel Thomson
18-09-2002, 08:18 PM
Thankyou parry, I had just found the isnumeric function on w3 schools so thankyou for your help.

parry
18-09-2002, 08:28 PM
My pleasure. Must be a real pain without the help files. If you have MSOffice you could ltry looking in the VB editor and go to help there as the statements and syntax are pretty much the same. :-)


 

TOP

For more info

 Information needed
 Easy method to re-nam
 "Enhanced" Audio CD
 Runtime error
 parallel port
 Modems Internal vs Ex
 Changing e-mail addre
 Shareaza Uploads Help
 NHL Help Me Please
 newdot

News Archive

 Vertical line problem
 Bring Back Hibernatio
 Dial-up Setting
 Windows 98 crashes
 Email Address Wanted
 unwanted hard-drive a
 Linux Floppy
 *.prn files  -  do th
 Outlook Download/Atta
 M1122 no good for SSH

Related stories:

Upgrade H.D
Connection to capture driver failure
AVG Update
Multiple SCSI Bus Resets Occur with a FireWire (1394) Controler
Log users on NT network
Correct Disposal old H/ware
cs sprays
Software 4 CPU heat measurement & motherboard reporting.

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics