Hi! (sorry for my English)

I'm storing the value of a TextBox in a variable named "i"
I want to validate "i" so it can only store numbers (great than 0)

and not letters.

If i < 1 OR i "is a letter" then
msgbox("wrong value...blabla")
end if

How can I validate that "i" is (or not) a letter

Re: Validate


Hi PYA-Ferro,

You can use this,

abc = application.InputBox (prompt:="Enter a value", title:="ONLY VALUE", TYPE:=1)


Re: Validate


Hi ix

But my Textbox is in a Form and I don't want to change the Form, just validate the value once entered.

(if I add your code, then the textbox in my form is no needed anymore).

The Form has a lot of buttons and textboxs and I don't want to add more steps to get a value from the user. Just want to validate a variable.

Thanks for the reply!

Re: Validate

Cringing Dragon

The IsNumeric function tests to see if an expression can be evaluated as a number. You could use the following for the first line of your if statement.

If i < 1 OR not IsNumeric(i) then

Re: Validate


Thaaanks, that's it!

Problem solved.