VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Enhanced Split Function (2D) (Fixed)

by Paul Robins (1 Submission)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

This code is an addon to the "split" function in VB, it takes an string and will split it into a 2D array. It's pretty easy to figure out. I wasn't sure whether to put this as a beginner or intermediate so it is kinda inbetween. If you're using VB5 or before you'll need to download a replacement split function from this site somewhere.
Latest - Fixed a small problem with different sizes of one dimension (could have been fixed with on error resume next but this is more effective)

Rate Enhanced Split Function (2D) (Fixed)

Private Function Split2D(StringToSplit, FirstDelimiter, SecondDelimiter)
Dim X As Integer, _
  Y As Integer, _
  FirstBound As Integer, _
  SecondBound As Integer, _
  ResultArray()
temparray = Split(StringToSplit, FirstDelimiter)
FirstBound = UBound(temparray)
For X = 0 To FirstBound
  temparray2 = Split(temparray(X), SecondDelimiter)
  If UBound(temparray2) > SecondBound Then SecondBound = UBound(temparray2)
Next
ReDim ResultArray(FirstBound, SecondBound)
For X = 0 To FirstBound
    temparray2 = Split(temparray(X), SecondDelimiter)
  For Y = 0 To UBound(temparray2)
    ResultArray(X, Y) = temparray2(Y)
  Next
Next
Split2D = ResultArray
End Function

Download this snippet    Add to My Saved Code

Enhanced Split Function (2D) (Fixed) Comments

No comments have been posted about Enhanced Split Function (2D) (Fixed). Why not be the first to post a comment about Enhanced Split Function (2D) (Fixed).

Post your comment

Subject:
Message:
0/1000 characters