Consulting

Results 1 to 2 of 2

Thread: What's the difference between the dims of Array ?

  1. #1

    What's the difference between the dims of Array ?

    Type 1
    Sub Break_String()  
        Dim WrdString As String  
        Dim text_string As String  
        text_string = "Welcome to Excel Trick"  
        WrdString = Split(text_string)(2)  
        MsgBox "The third part is : " & WrdString  
        End Sub
    Type 2
    Sub Break_String()  
        Dim WrdArray() As String  
        Dim text_string As String  
        text_string = "Welcome to Excel Trick"  
        WrdArray() = Split(text_string)  
        For i = LBound(WrdArray) To UBound(WrdArray)  
          strg = strg & vbNewLine & "Part No. " & i & " - " & WrdArray(i)  
        Next i  
        MsgBox strg  
        End Sub

    What is the difference between the two types of use, with or without parentheses?
    Last edited by Aussiebear; 01-10-2019 at 08:42 PM. Reason: Added tags to submitted code

  2. #2
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    832
    Location
    The 1st one gives U the location in the Split array ie. posn 3 in your eg. re. option base 0 for Split (syntax looks wrong??). The 2nd one I believe creates a paraarray (not sure?) and contains the whole string parsed by the Split which is useful if the Split criteria is known eg. a comma. By the way U need to Split a text string by some other text string. Check the Split syntax. HTH. Dave

Posting Permissions

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