Private Sub Form_Load()
Text1Text = "G1,G2,G3,G4,G8,A1,A3,C4,E1,E2"
'Text1Text = "G5,G6,G7,G9,G10,G12 "
End Sub
Private Sub Command1_Click()
MeCls
Print cHange(Text1Text) '调用change函数
End Sub
Private Function sTi(ByVal qt As String) As String
For i = 1 To 50
If IsNumeric(Right(Trim(qt), i)) Then
DoEvents
Else
sTi = Left(qt, Len(qt) - i + 1)
Exit Function
End If
Next i
End Function
Private Function num(ByVal qw As String) As Long
For i = 1 To 50
If IsNumeric(Right(Trim(qw), i)) Then
num = Right(Trim(qw), i)
Else
Exit Function
End If
Next i
End Function
Private Function cHange(ByVal qq As String) As String
Dim MyString
Dim temp1 As Long, temp2 As Long, temp3 As String, i As Long, k As Long
MyString = Split(Trim(qq), ",")
temp1 = 0: temp2 = 0: cHange = "": k = 0
For i = 0 To UBound(MyString)
If i = 0 Or (temp2 <> num(MyString(i))) Or (sTi(MyString(i)) <> temp3) Then
If i <> 0 Then
If k = 1 Then
cHange = cHange & "~" & Trim(MyString(i - 1)) & "," & MyString(i)
Else
cHange = cHange & "," & MyString(i)
End If
Else
cHange = MyString(i)
End If
temp2 = num(MyString(i))
temp3 = sTi(MyString(i))
k = 0
Else
k = 1
End If
If i = UBound(MyString) And k = 1 Then cHange = cHange & "~" & Trim(MyString(i))
temp2 = temp2 + 1
Next i
End Function
以上就是关于用VB实现这样的合并全部的内容,包括:用VB实现这样的合并、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)