Results 1 to 40 of 45

Thread: Is Split Buggy? Why Isn't 0 a Number?

Threaded View

  1. #1

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397

    Is Split Buggy? Why Isn't 0 a Number?

    This is weird.
    Could anyone Try this code and tell me if 0 is consistently a number or not?

    VB Code:
    1. Private Sub Command2_Click()
    2.     Dim MY_STR As String
    3.     MY_STR = "1 + 0"
    4.     MY_STUFF = Split(MY_STR, " ", -1, vbTextCompare)
    5.     For Each One In MY_STUFF
    6.         Select Case One
    7.             Case ""
    8.                 MsgBox "NULL"
    9.             Case "+"
    10.                 MsgBox "PLUS"
    11.             Case IsNumeric(One) = True
    12.                 MsgBox One & " is a Number"
    13.             Case Else
    14.                 MsgBox One & " is Not a Number"
    15.         End Select
    16.     Next One
    17.     MY_STR = "0"
    18.     If IsNumeric(MY_STR) Then
    19.         MsgBox MY_STR & " is a number"
    20.     Else
    21.         MsgBox MY_STR & " is NOT a number"
    22.     End If
    23. End Sub

    The following is even worse, 1 isn't even a number anymore!

    VB Code:
    1. Private Sub Command2_Click()
    2.     Dim MY_STR As String
    3.     Dim Two As String
    4.     MY_STR = "1 + 0"
    5.     MY_STUFF = Split(MY_STR, " ", -1, vbTextCompare)
    6.     For Each One In MY_STUFF
    7.         Two = One
    8.         Select Case Two
    9.             Case ""
    10.                 MsgBox "NULL"
    11.             Case "+"
    12.                 MsgBox "PLUS"
    13.             Case IsNumeric(Two) = True
    14.                 MsgBox Two & " is a Number"
    15.             Case Else
    16.                 MsgBox Two & " is Not a Number"
    17.         End Select
    18.     Next One
    19. End Sub

    Am I Missing something? Or should I ReBoot / ReIntsall VB?


    -Lou

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width