In VBScript, how does one go about ensuring the response to an input box is
greater than 0 and less than 5? This also means error trapping for blank
entry and text entries, etc.

Your example script would be most helpful, thanks...

Re: Validate entry from input box by S

S
Wed Jul 25 08:48:58 CDT 2007

intReturnValue = InputBox()
If intReturnValue < 0 Or intReturnValue > 5 Then
'error trapped, do something
End If




"XP" <XP@discussions.microsoft.com> wrote in message
news:83986B87-572A-4FD3-BF85-2CC0994665E7@microsoft.com...
> In VBScript, how does one go about ensuring the response to an input box
> is
> greater than 0 and less than 5? This also means error trapping for blank
> entry and text entries, etc.
>
> Your example script would be most helpful, thanks...
>


Re: Validate entry from input box by XP

XP
Wed Jul 25 09:02:06 CDT 2007


Thanks, but if OK is pressed without entering anything (i.e. a blank) and
also text both generate type mismatch errors for me...how can these also be
trapped?


"S Moran" wrote:

> intReturnValue = InputBox()
> If intReturnValue < 0 Or intReturnValue > 5 Then
> 'error trapped, do something
> End If
>
>
>
>
> "XP" <XP@discussions.microsoft.com> wrote in message
> news:83986B87-572A-4FD3-BF85-2CC0994665E7@microsoft.com...
> > In VBScript, how does one go about ensuring the response to an input box
> > is
> > greater than 0 and less than 5? This also means error trapping for blank
> > entry and text entries, etc.
> >
> > Your example script would be most helpful, thanks...
> >
>
>

Re: Validate entry from input box by mr_unreliable

mr_unreliable
Wed Jul 25 11:06:59 CDT 2007

xp, this is a frequently asked question.

You can find your answer among numerous previous postings.

Go to google advanced group search:

http://groups.google.com/advanced_group_search

and search for "inputbox" and "cancel button".

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)



XP wrote:
> Thanks, but if OK is pressed without entering anything (i.e. a blank) and
> also text both generate type mismatch errors for me...how can these also be
> trapped?
>
>
> "S Moran" wrote:
>
>> intReturnValue = InputBox()
>> If intReturnValue < 0 Or intReturnValue > 5 Then
>> 'error trapped, do something
>> End If
>>
>>
>>
>>
>> "XP" <XP@discussions.microsoft.com> wrote in message
>> news:83986B87-572A-4FD3-BF85-2CC0994665E7@microsoft.com...
>>> In VBScript, how does one go about ensuring the response to an input box
>>> is
>>> greater than 0 and less than 5? This also means error trapping for blank
>>> entry and text entries, etc.
>>>
>>> Your example script would be most helpful, thanks...
>>>
>>

Re: Validate entry from input box by Alexander

Alexander
Thu Jul 26 02:30:10 CDT 2007

XP schrieb:

> In VBScript, how does one go about ensuring the response to an input box is
> greater than 0 and less than 5? This also means error trapping for blank
> entry and text entries, etc.
>
> Your example script would be most helpful, thanks...
>

Dim vInput

vInput = InputBox("Enter a value from 1 to 4")
If IsNumeric(vInput) Then
If vInput > 0 And vInput < 5 Then
Msgbox "Value " & vInput & " is valid", vbInformation
Else
Msgbox "Value " & vInput _
& " is not valid", vbExclamation
End If
End If


MfG,
Alex

Re: Validate entry from input box by Dr

Dr
Thu Jul 26 07:58:20 CDT 2007

In microsoft.public.scripting.vbscript message <83986B87-572A-4FD3-BF85-
2CC0994665E7@microsoft.com>, Wed, 25 Jul 2007 06:38:10, XP
<XP@discussions.microsoft.com> posted:
>In VBScript, how does one go about ensuring the response to an input box is
>greater than 0 and less than 5? This also means error trapping for blank
>entry and text entries, etc.

The entry will be a string. Use a RegExp to test it for containing
exactly one digit in the range 1 to 5 and nothing else. But you might
allow leading zeroes.

Input validation is generally best done using a RegExp, though actual
numeric value is generally best done by subsequent arithmetic test.

--
(c) John Stockton, Surrey, UK. ???@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.