Results 1 to 4 of 4

Thread: Split() Help ASAP Please!

  1. #1

    Thread Starter
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155
    Im using Split to parse a string with a statment like:
    Code:
    Dim X As Variant
    X = Split(InputData$, "|")
    Does anyone know how to see how many fields that Split created because if I try to MsgBox X(99) but the string only contained 98 fields, I get an error, how can I see how many fields it created in X?

  2. #2
    Guest
    Use UBound() to get the highest index.

    Code:
    Retval = Split("One|Two|Three|Four", "|")
    
    For I = 0 To UBound(Retval)
        Print Retval(I)
    Next I

  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Code:
      'PURPOSE:Break up string basing on " " and stick into an array
      Dim str_Split() As String
      str_Split = Split("How | Are | You", "|")
      MsgBox "There are " & UBound(str_Split) & " occurence."
      
      Dim int_X As Integer
      Dim str_Data As String
      For int_X = LBound(str_Split) To UBound(str_Split)
        str_Data = str_Data & vbCrLf & str_Split(int_X)
      Next
      MsgBox str_Data
    Chemically Formulated As:
    Dr. Nitro

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    Count = ubound(split("A|B|C","|")) + 1
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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