VB6 Split Function in VB5
This code duplicates the functionality of VB6's split function.
AI
Yapay Zeka Özeti: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Kaynak Kod
Function Split(TheString As String, Optional Delim As String, Optional Limit As Long = -1) As Variant
'Duplicates the functionality of the vb6 counterpart.
'Unfortunately, I was unable to include the vbcompare part of the vb6 funtionality.
'Just use Option Campare at the beggining of this module.
Dim dynArray() As Variant
If Len(Delim) > 0 Then
Dim ArrCt%
Dim CurPos%
Dim LenAssigned%
Dim CurStrLen%
ArrCt% = 0
CurPos% = 1
LenAssigned% = 1
CurStrLen% = Len(TheString$)
Do
ReDim Preserve dynArray(0 To ArrCt%)
CurStrLen% = (InStr(CurPos%, TheString$, Delim$) - CurPos%)
If CurStrLen% < 0 Then
dynArray(ArrCt%) = Right$(TheString$, (Len(TheString$) - (LenAssigned% - 1)))
Exit Do
Else
dynArray(ArrCt%) = Mid$(TheString$, CurPos%, CurStrLen%)
End If
LenAssigned% = LenAssigned% + (Len(dynArray(ArrCt%)) + Len(Delim$))
CurPos% = LenAssigned%
ArrCt% = ArrCt% + 1
If Not Limit = -1 Then
If ArrCt = Limit Then Exit Do
End If
Loop
Split = dynArray
Else
'duplicate the functionality more acuratley
ReDim dynArray(0 To 0)
dynArray(0) = TheString
Split = dynArray
End If
End Function
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı