Results 1 to 5 of 5

Thread: Split Function

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Gig Harbor, WA; Posts: 89950
    Posts
    360
    I guess I should have been more clear. Can someone please explain to me the split function.
    Can it seperate a string like "KooKooKaChoo" into 12 different strings,
    (or more preferrable) 1 stringarray?

    Like say...Oh I don't know...strWheresWaldo(11) as string?????

    Thanks!
    Lee
    Mahalo
    VB6(SP5), VC++, COBOL, Basic, JAVA
    MBA, MCSD, MCSE, A+
    Computer Forensics

  2. #2
    Lively Member
    Join Date
    Sep 2000
    Location
    NC, USA
    Posts
    102

    Talking

    check the other thread.

  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Copy this to a module and try this. It split on each space and sticks into an array.

    Code:
    Option Explicit
    
    Sub Main()
      'PURPOSE:Break up string basing on " " and stick into an array
      Dim str_Split() As String
      str_Split = Split("Koo Koo Ka Choo", " ")
      
      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
    End Sub

    If you want 12 different string, copy this instead.
    Code:
    Option Explicit
    
    Sub Main()
      Dim str_Split(11) As String
      Dim int_X As Integer
      
      Dim str_Data As String
      str_Data = "KooKooKaChoo"
      For int_X = 0 To Len(str_Data) - 1
        str_Split(int_X) = Mid(str_Data, int_X + 1, 1)
        MsgBox str_Split(int_X)
      Next
    End Sub
    Chemically Formulated As:
    Dr. Nitro

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Gig Harbor, WA; Posts: 89950
    Posts
    360

    Talking

    You are truly ..."The Master!"

    Thanks
    Lee
    Mahalo
    VB6(SP5), VC++, COBOL, Basic, JAVA
    MBA, MCSD, MCSE, A+
    Computer Forensics

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Option Explicit
    Code:
    'you can split on spaces like this as well
    
    Private Sub Command1_Click()
        
        Dim myVar As Variant  'has to be variant
        Dim strData As String
        strData = "Koo Koo Ka Choo"
        myVar = Split(strData, " ")
    
    'for display only
    
        Dim x As Integer, msg As String
        
        For x = LBound(myVar) To UBound(myVar)
           msg = msg & myVar(x) & vbCrLf
        Next x
        
       MsgBox msg
        
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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