Archive for 2010 年 07 月

由string中提取由某符號(本例用",")相隔的各個data

七月 12, 2010

要list1,command1,text1,text2

Dim first, sec As Integer
Dim str1 As String
Private Sub Command1_Click()
On Error Resume Next
first = 0
sec = 0
str1 = Text1
Text1 = Text1 & “,"
For i = 1 To 40
sec = InStr(first + 1, Text1, “,") ‘開頭1 ,insert
If sec < first Then Exit For
Text1.SelStart = first ‘開頭0

Text1.SelLength = sec – first – 1
List1.AddItem (Text1.SelText)
first = sec
Next i
Text1 = str1
For i = 0 To List1.ListCount
Print List1.List(i)
Next i
End Sub

本例由text1提取到list1,可提取list1.list(i)到其他地方
當然可以換其他符號,要同時換兩處