russell12
asked on
read a negative number in a text box
I need to know how I can write a code in vba to read if a textbox has a negative value. For example if textbox1.value = "-1" then msgbox "negative value". this is not only restricted to -1, it goes for any "-" value. Any help will be greatly appreciated!!! Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
IrogSinta
We posted at the same time I guess, but I am accepting your solution! I knew it was easy to do, and when I posted it, I thought about it for a minute and wrote that case statement that worked excellent!! Thanks though for the quick response! I really appreciate all the experts on this forum. Signing up for this forum was the best move I have ever made!! Thanks for the help!!
We posted at the same time I guess, but I am accepting your solution! I knew it was easy to do, and when I posted it, I thought about it for a minute and wrote that case statement that worked excellent!! Thanks though for the quick response! I really appreciate all the experts on this forum. Signing up for this forum was the best move I have ever made!! Thanks for the help!!
Thanks, regarding your solution, I'm not sure what you had in mind when concatenating a null string to your text and then using the Trim function. I believe if you had just used Select Case Text7 it would work fine too.
ASKER
Well for some reason, when I do not put "Trim", the case statement will not read a null value. It does not make any sense, because I can write an if statement and it works just fine. But again, thanks for your help.
Just for future reference, you can always use the Nz function to handle null values.
For instance, Nz(Text7,0) would change a null value to 0.
For instance, Nz(Text7,0) would change a null value to 0.
ASKER
Select Case Trim("" & Text7)
Case Is <= 0
MsgBox "negative"
Case Else
MsgBox "postive"
End Select
thanks again in advance!!