2,462
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Sub Command1_Click()
Dim aBuff() As String
Dim strText As String
Dim p1&, p2 As Long
Dim i As Long
strText = "{Name :""廪廷鑫""," & _
"CardNo. :""370786199103145417"", " & _
"Sex :""男""," & _
"Birthday :""1991年03月14日""," & _
"Address :""山东省昌邑市作山镇颜家庄村127号""," & _
"Folk :""汉""}"
' 拆分项目
aBuff = Split(strText, ",")
' 提取数据
For i = 0 To UBound(aBuff)
strText = aBuff(i)
p1 = InStr(1, strText, ":") + 2&
p2 = InStr(p1, strText, """")
aBuff(i) = Mid$(strText, p1, p2 - p1)
Next
' 显示处理结果:
For i = 0 To UBound(aBuff)
Debug.Print i + 1; aBuff(i)
Next
End Sub
' 处理结果:
' 1 廪廷鑫
' 2 370786199103145417
' 3 男
' 4 1991年03月14日
' 5 山东省昌邑市作山镇颜家庄村127号
' 6 汉
Option Explicit
Private Sub Command1_Click()
Dim w1 As String, i As Integer, ww, wd
w1 = Replace(Text1.Text, "{", "")
w1 = Replace(w1, "}", "")
w1 = Replace(w1, """", "")
ww = Split(w1, ",")
If UBound(ww) = 5 Then
For i = 0 To UBound(ww)
wd = Split(ww(i), ":")
If UBound(wd) = 1 Then Text2(i).Text = wd(1)
Next
End If
End Sub
....