simple vb question
simple vb question
(OP)
I am writing a bit of code to run with a macro in SW. I have the following:
If txtNumber.Text <> IsNumeric Then
MsgBox ("Use only numbers.")
GoTo waithere
End If
The IsNumeric give an error "The argument is not optional" I have a test box being populated with 5 characters I want to ensure that only numbers are uses else give the error "use only numbers"
Any thoughts on making this work.
Thanks,
Josh
If txtNumber.Text <> IsNumeric Then
MsgBox ("Use only numbers.")
GoTo waithere
End If
The IsNumeric give an error "The argument is not optional" I have a test box being populated with 5 characters I want to ensure that only numbers are uses else give the error "use only numbers"
Any thoughts on making this work.
Thanks,
Josh






RE: simple vb question
Regards
vik
RE: simple vb question
If (Not IsNumeric(txtNumber.Text)) Then
MsgBox ("Use only 5 digit number at end of file name.")
GoTo waithere
End If
RE: simple vb question
CODE
MyCheck = IsNumeric(MyVar) ' Returns False.
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: simple vb question
Regg
RE: simple vb question
To be honest with you I dont know the purpose. I am about 3 days into programming with VB. I found that code on the www, copied it and tweaked it to look for txt.number.txt.
RE: simple vb question
You're right, but you must be tolerant. Some of us are not programmers (or didn't learn this type of object/event driven language at school). Some hepful macros are done just "by gathering" some lines of code and a lot of trial and error. They may not look nice or reveal a good programming practice, but if they work then they are fine!
Regards
RE: simple vb question
"waithere" must be the name of a line in the program. Look for a line that says "waithere:"--the colon denotes that it is the name for a line used for GoTo.
RE: simple vb question
RE: simple vb question
If you want users to limit data entry to 5 digit numbers, you should use the following two functions in VB (or VBA):
1. Set your text box length to 5;
2. Use "IsNumeric()" command.
Alex