第1个回答 推荐于2017-11-26
1个Split就能解决你的问题
Dim lie() As String
Open App.Path & "\*.txt" For Input As #1 ' 打开你的*.txt文件。
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
lie = Split(TextLine, ";") ’分列
MsgBox lie(0)'显示第一列内容
Loop
Close #1 ' 关闭文件
lie(0)为1、2、3、4、
lie(1)为aaa、bbb、ccc、ddd、xxx本回答被提问者采纳
第2个回答 2008-12-18
呵呵,楼下的好懒啊,哈
不知是TEXT文本框控件还是一个.txt文本文件,
如果是文件要先导入哦.
一切从简,如果是text控件的话是很简单的,假设数据在txt1.text
dim a() as string
dim b() as string
a=split(txt1.text,vbnewline)
for i = lbound(a()) to ubound(a())
b=split(a(i),";")
'做你想做既代码
分号前=b(0)
分号后=b(1)
'你的代码结束
erase b()
next i
第3个回答 2008-12-18
你说的那个可以用streamreader 和string 的 split function 做。 懒得写code -_- 自己看看msdn上的例子吧。
第4个回答 2008-12-18
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function fileStr(ByVal fName As String) As String
On Error GoTo Err1
Dim tempInput As String
Open fName For Input As #1
Do While Not EOF(1)
Line Input #1, tempInput
If Right(tempInput, 1) <> Chr(10) Then tempInput = tempInput & Chr(10)
tempInput = Replace(tempInput, Chr(10), vbCrLf)
fileStr = fileStr & tempInput
Loop
If fileStr <> "" Then fileStr = Left(fileStr, Len(fileStr) - 2)
Close #1
Exit Function
Err1:
MsgBox "²»´æÔÚ¸ÃÎļþ»ò¸ÃÎļþ²»ÄÜ·ÃÎÊ£¡", vbExclamation
End Function
str=fileStr("txt路径")
a()=split(str,vbnewline)
for i=0 to n
b()=split(a(n),",")
text1.text=b(0) & " 、"
text1.text=b(1) & " 、"
next