IsNumeric problem

IsNumeric problem

Post by KCLa » Sun, 06 Jul 2003 12:57:10



Why is the following function not working? Calling it
returns nothing. (I use exactly the same code with IsDate
() and it worked perfectly)

Private Function getNumber(sPrompt As String, sAction As
String, sValue As Variant) As String
Dim iInput As Variant
While Not IsNumeric(iInput)
  iInput = InputBox(sPrompt, sAction, sValue)
  If iInput <> "" Then
    If Not IsNumeric(iInput) Then
      MsgBox "Invalid format" & vbCrLf & _
             "You input: " & "'" & iInput & "'" & vbCrLf _
             "Numbers only", , "GetNumber"
    Else
      getNumber = iInput
      Exit Function
    End If
  Else
    Exit Function
  End If
Wend
End Function

 
 
 

IsNumeric problem

Post by Lonn » Sun, 06 Jul 2003 18:44:32



Quote:> Why is the following function not working? Calling it
> returns nothing. (I use exactly the same code with IsDate
> () and it worked perfectly)

> Private Function getNumber(sPrompt As String, sAction As
> String, sValue As Variant) As String
> Dim iInput As Variant
> While Not IsNumeric(iInput)
>   iInput = InputBox(sPrompt, sAction, sValue)
>   If iInput <> "" Then
>     If Not IsNumeric(iInput) Then
>       MsgBox "Invalid format" & vbCrLf & _
>              "You input: " & "'" & iInput & "'" & vbCrLf _
>              "Numbers only", , "GetNumber"
>     Else
>       getNumber = iInput
>       Exit Function
>     End If
>   Else
>     Exit Function
>   End If
> Wend
> End Function

Perhaps if you initialise iInput.
The chances of it being numeric are high, but of it being a date... low.

Lonny

 
 
 

IsNumeric problem

Post by Andy Clapha » Mon, 07 Jul 2003 04:34:52


It's a strange bug/feature in VB Script, that empty is considered numeric.
An unitialsied vairable is empty.




> > Why is the following function not working? Calling it
> > returns nothing. (I use exactly the same code with IsDate
> > () and it worked perfectly)

> > Private Function getNumber(sPrompt As String, sAction As
> > String, sValue As Variant) As String
> > Dim iInput As Variant
> > While Not IsNumeric(iInput)
> >   iInput = InputBox(sPrompt, sAction, sValue)
> >   If iInput <> "" Then
> >     If Not IsNumeric(iInput) Then
> >       MsgBox "Invalid format" & vbCrLf & _
> >              "You input: " & "'" & iInput & "'" & vbCrLf _
> >              "Numbers only", , "GetNumber"
> >     Else
> >       getNumber = iInput
> >       Exit Function
> >     End If
> >   Else
> >     Exit Function
> >   End If
> > Wend
> > End Function

> Perhaps if you initialise iInput.
> The chances of it being numeric are high, but of it being a date... low.

> Lonny

 
 
 

IsNumeric problem

Post by Andy Clapha » Mon, 07 Jul 2003 10:32:13


Or uninitialised.... oh well...
 
 
 

IsNumeric problem

Post by KCLa » Mon, 07 Jul 2003 14:51:54


Thanks, that's why!
Quote:>-----Original Message-----
>Or uninitialised.... oh well...

>.

 
 
 

1. O2 xda problems, problems

On a recent visit to Singapore I bought an O2xda and it worked just
fine for 4 days. This morning when I pressed the power up button I had
a blank screen. I pressed the contacts button and the screen dissolved
into vertical lines. I tried a soft and hard reset then removed and
replaced the SIM & MM card. No different. I hit the website
www.myxda.com and emailed the SIngapore helpline - it was bounced as
address unknown. I then tried the helpline for Malaysia and HK with
the same result. Tried the only other contact for general queries and
that was the same.
Does anybody know who the manufacturer is and what their email address
is? The handbook doesnt list it. The warranty card lists the email
addresses I have already tried. I am impressed with the xda but
definitely not impressed with the company that makes it or the gook
that posted non-existant helpline email addresses on the website. I am
beginning to wish I had bought the Nokia instead - at least they are a
reputable and contactable company.

2. @Home again in the News

3. WordLogic problem (Norwegian language problem)

4. modem

5. IMAP problems, too (2002 modem problems not just for smtp anymore!)

6. NeWSprinter 20 --duplex?

7. iPAQ USB & SYNC Problem FAQ - Problem Resolutions

8. SNES console copier=> Amiga

9. list view problem (yes, another problem! sorry)

10. Problem.. Problem....

11. iPAQ screen problem - not mirror problem

12. HELP: problems upgrade to 1.77 COULD be the problem

13. lots of problems or problems means to me alot