VB读txt文件除去特定字符
如某一txt内容为1,aaaaa,bbb2,eee,dd3,dggggg,iuowi在text1输入1时,text2.text=aaaaa,text3.text=bbb在...
如某一txt内容为
1,aaaaa,bbb
2,eee,dd
3,dggggg,iuowi
在text1输入1时,text2.text=aaaaa,text3.text=bbb
在text1输入2时,text2.text=eee,text3.text=dd
……
两串字符不等长
高手求解! 展开
1,aaaaa,bbb
2,eee,dd
3,dggggg,iuowi
在text1输入1时,text2.text=aaaaa,text3.text=bbb
在text1输入2时,text2.text=eee,text3.text=dd
……
两串字符不等长
高手求解! 展开
3个回答
展开全部
Private Sub Text1_Change()
Me.Text2.Text = ""
Me.Text3.Text = ""
Open "c:\a.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, q
p = Split(q, ",")
If Me.Text1.Text = p(0) Then
Me.Text2.Text = p(1)
Me.Text3.Text = p(2)
End If
Loop
Close #1
End Sub
【说明】
添加3个TextBox控件,默认这个txt文件位置是"c:\a.txt"
Me.Text2.Text = ""
Me.Text3.Text = ""
Open "c:\a.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, q
p = Split(q, ",")
If Me.Text1.Text = p(0) Then
Me.Text2.Text = p(1)
Me.Text3.Text = p(2)
End If
Loop
Close #1
End Sub
【说明】
添加3个TextBox控件,默认这个txt文件位置是"c:\a.txt"
展开全部
Dim s() As String, ss() As String, i As Integer
Open "123.txt" For Binary As #1
s = Split(Input(LOF(1), #1), vbCrLf)
Close #1
For i = 0 To UBound(s)
ss = Split(s(i), ",")
If UBound(ss) = 2 Then
If Trim(Text1.Text) = Trim(ss(0)) Then
Text2.Text = ss(1)
Text3.Text = ss(2)
Exit For
End If
End If
Next
Open "123.txt" For Binary As #1
s = Split(Input(LOF(1), #1), vbCrLf)
Close #1
For i = 0 To UBound(s)
ss = Split(s(i), ",")
If UBound(ss) = 2 Then
If Trim(Text1.Text) = Trim(ss(0)) Then
Text2.Text = ss(1)
Text3.Text = ss(2)
Exit For
End If
End If
Next
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
被拒后果
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询