文本中每行有三个数据,有2千行,需用VB,使首数是462,463,464的行删除,其他的行保留三个数中后两个.

来源:百度知道 编辑:UC知道 时间:2024/09/21 08:27:36
本人将不甚感谢!事情十万火急啊!
hmkikikaki,非常感谢您的帮助,程序我试过,有些出入.我的意思是把有462 463 464的行删除,而其他不是这三个数开头的行则保留其后两位,请您帮我再调试下,非常感谢.
例如:463,5489,4543
23,45,45435
结果要求是:45,45435

新建一个窗口,在上面添加一个command按钮和一个文本框,分别命名为Command1和Text1,然后把text1的MultiLine属性设为true

然后在窗体中添加如下代码

Private Sub Command1_Click()
Dim strTemp As String
Dim Temp As String

Open App.Path & "\11.txt" For Input As #1

Text1.Text = ""
Do While Not EOF(1)
strTemp = ""

Line Input #1, strTemp
Temp = Left(strTemp, 3)
If Temp = "462" Or Temp = "463" Or Temp = "464" Then
Text1.Text = Text1.Text & Right(strTemp, Len(strTemp) - 4)
Else
Text1.Text = Text1.Text & strTemp
End If
Text1.Text = Text1.Text & vbCrLf
Loop
End Sub

windows XP SP2 + VB6.0 SP6
追梦人 调试通过