那个split函数是在网上找的,可是好象不行啊。请大虾看看。Private Sub Command1_Click()
Call show1
End SubSub show1()
Dim strSj() As Variant
strSj = split_vb5("a,yj,708", ",")
MsgBox strSj(1)
End SubPrivate Function split_vb5(ByVal sstr As String, spstr As String) As Variant
Dim starstr, lenstr, cur As Integer
Dim backstr() As String
starstr = InStr(sstr, spstr)
cur = starstr + 1
lenstr = Len(sstr)
ReDim backstr(0)
backstr(0) = Left(sstr, starstr - 1)
For x = starstr + 1 To lenstr
If Mid(sstr, x, 1) = spstr Then
ReDim Preserve backstr(UBound(backstr) + 1)
backstr(UBound(backstr)) = Mid(sstr, cur, x - cur)
cur = x + 1
Debug.Print backstr(UBound(backstr))
End If
Next
split_vb5 = backstr()
End FunctionPrivate Function InStrRev_vb5(ByVal start As Integer, ByVal str1 As String, ByVal str2 As String)
str1 = revstr(str1)
str2 = revstr(str2)
start = Len(str1) - start
InStrRev_vb5 = Len(str1) - InStr(start, str1, str2)
End FunctionPrivate Function revstr(str As String) As String
Dim x, lenstr As Integer
lenstr = Len(str)
For x = lenstr To 1 Step -1
revstr = revstr & Mid(str, x, 1)
Next
End Function
Call show1
End SubSub show1()
Dim strSj() As Variant
strSj = split_vb5("a,yj,708", ",")
MsgBox strSj(1)
End SubPrivate Function split_vb5(ByVal sstr As String, spstr As String) As Variant
Dim starstr, lenstr, cur As Integer
Dim backstr() As String
starstr = InStr(sstr, spstr)
cur = starstr + 1
lenstr = Len(sstr)
ReDim backstr(0)
backstr(0) = Left(sstr, starstr - 1)
For x = starstr + 1 To lenstr
If Mid(sstr, x, 1) = spstr Then
ReDim Preserve backstr(UBound(backstr) + 1)
backstr(UBound(backstr)) = Mid(sstr, cur, x - cur)
cur = x + 1
Debug.Print backstr(UBound(backstr))
End If
Next
split_vb5 = backstr()
End FunctionPrivate Function InStrRev_vb5(ByVal start As Integer, ByVal str1 As String, ByVal str2 As String)
str1 = revstr(str1)
str2 = revstr(str2)
start = Len(str1) - start
InStrRev_vb5 = Len(str1) - InStr(start, str1, str2)
End FunctionPrivate Function revstr(str As String) As String
Dim x, lenstr As Integer
lenstr = Len(str)
For x = lenstr To 1 Step -1
revstr = revstr & Mid(str, x, 1)
Next
End Function
Call show1
End SubSub show1()
Dim strSj() As String
strSj = split_vb5("a,yj,708", ",")
MsgBox strSj(1)
End SubPrivate Function split_vb5(ByVal sstr As String, spstr As String) As String()
Dim starstr, lenstr, cur As Integer
Dim backstr() As String, x As Long
starstr = InStr(sstr, spstr)
cur = starstr + 1
lenstr = Len(sstr)
ReDim backstr(0)
backstr(0) = Left(sstr, starstr - 1)
For x = starstr + 1 To lenstr
If Mid(sstr, x, 1) = spstr Then
ReDim Preserve backstr(UBound(backstr) + 1)
backstr(UBound(backstr)) = Mid(sstr, cur, x - cur)
cur = x + 1
Debug.Print backstr(UBound(backstr))
End If
Next
split_vb5 = backstr()
End FunctionPrivate Function InStrRev_vb5(ByVal start As Integer, ByVal str1 As String, ByVal str2 As String)
str1 = revstr(str1)
str2 = revstr(str2)
start = Len(str1) - start
InStrRev_vb5 = Len(str1) - InStr(start, str1, str2)
End FunctionPrivate Function revstr(str As String) As String
Dim x, lenstr As Integer
lenstr = Len(str)
For x = lenstr To 1 Step -1
revstr = revstr & Mid(str, x, 1)
Next
End Function我改了一下,你运行一下,应该没问题了
示例VB6.0 Dim youArry, strS As String, i As Long
strS = "1.2.3.11.111.1111"
youArry = Split(strS, ".")
For i = LBound(youArry) To UBound(youArry)
MsgBox youArry(i)
Next