vb字符串分割

发布网友 发布时间:2024-10-23 06:11

我来回答

2个回答

热心网友 时间:2024-10-24 15:33

如果格式总是固定为A,B,C|D,E 且分成
A
B,C
D,E
的话可以自己写一下函数
如果数据长度总是固定的话更简单用截取字符串就行了

Private Function SplitEx(ByVal s As String) As String() Dim t(2) As String Dim n1 As Integer, n2 As Integer n1 = InStr(1, s, ",") n2 = InStr(1, s, "|") t(0) = Left(s, n1 - 1) t(1) = Mid(s, n1 + 1, n2 - n1 - 1) t(2) = Right(s, Len(s) - n2) SplitEx = t End Function
Private Sub Form_Load() Dim s() As String s = SplitEx("1560321698,48,61|68,59") MsgBox s(0) MsgBox s(1) MsgBox s(2) End Sub

热心网友 时间:2024-10-24 15:33

dim a() as string
a=split("1560321698,48,61|68,59",",")
'那么
a(1)=1560321698
a(2)=48
a(3)=61
a(4)=59
望采纳

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com