Inputbox - Validate String

  • Thread starter Thread starter Todd Shillam
  • Start date Start date
T

Todd Shillam

I would like to know if anyone has a method (function) to validate a string
variable from an inputbox as a double.

For example, if a user attempts to enter a alphabetical character in the
string:

123r.45

I was hoping I could possible use an array using the variables length to
re-iterate the loop.

Otherwise, it looks like I'll just build a form. I'm open to suggestions
here.

Thanks in advance,

Todd
 
Use the IsNumeric function to verify the input on the Before_Update event of
the text box.

_______________________
Steve Huff
http://www.huffs.us
Generic email: null(removethis)@huffs.us
 
Steve,

Perfect--I never though of using a textbox. I was trying to parse the string
into characters earlier today. That's a great idea--thanks for the input.
Although, I wouldn't mind learning how to parse the input string into
characters and validate them in via script.

Thanks again,

Todd
 
I missed that you said you where using an InputBox, where is the input box
being initiated from? When ever it returns it's value verify it with
IsNumeric and then pop the InputBox back up.
 
Well you could parse it into characters if you want but it would be over
kill....

Here is a VERY QUICK AND UGLY way to parse a double passed to a function and
print each character out in the debug window:

Public Function testit(dblX As Double)
Dim s As String
Dim x As Integer
Dim y As Integer

s = CStr(dblX)
x = Len(s)
For y = 1 To x
Debug.Print Mid(s, y, 1)
Next y
End Function
 
Steve,

I have a textbox on a form for users to enter the number of gallons of fuel
that are dispensed during each fueling. Using the gallon textbox's
BeforeUpdate event, the subroutine has a temporary variable for the fuel
meter's reading (including the additional gallons of the current record).
The inputbox is simply being used to validate between what is being entered
and the actual meter reading itself--the idea here is that I am trying to
alert the user if something is not correct, beit the meter reading or the
user entered the incorrect number of gallons.

So I need the user input to be a double variable to perform the comparison.
I also want to alert the user if they enter invalid input.

Thanks for the help,

Todd
 
Back
Top