View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
pallaver pallaver is offline
external usenet poster
 
Posts: 62
Default Verify Textbox Information is a Number and Not Text

So I have a UserForm asking for a couple of different values. These
values should all be numbers.

I already added so that the program doesn't continue if the Textbox
value is "" (blank).

How do I make it not continue if the Textbox value is not a number,
i.e. text only, or text and a number?

I've tried the following two ideas:

XVariance = UserForm1.TextBoxXVariance.Text

1. If Val(XVariance)/1 = Val(XVariance) then ...... else exit sub end
if
2. Const TextCharacters = "abcdefghijklmnopqrstuvwxyz" and If
InStr(XVariance, TextCharacters) Then Exit Sub

I just want to make sure the Textbox contains a number using only
0123456789 and a decimal point.

Seems pretty simple and straightforward, but I'm stuck.

Thankx, NP