已经有这样一段代码:
Private Sub Command4_Click()
Dim ReDat As String '存读入的文字
Dim MidDat As String '第一个逗号前的内容
Dim SavDat() As String '处理之后的内容
Dim i As Variant '用作数组的下标,j同
Dim j As Variant
Open App.Path & "\123.txt" For Input As #1 '打开文件
Do While Not EOF(1) '循环读取到文件尾
Line Input #1, ReDat '读入一行
MidDat = Left(ReDat, InStr(1, ReDat, ",", vbTextCompare) - 1) '得到第一个逗号前的内容
If MidDat = Label1.Caption Then '如果与Label1.Caption的内容相匹配的一行,并在这一行后面加上:
ReDat = ReDat & "," & Mid(Label4.Caption, 3, 2) & Mid(Label4.Caption, 6, 2) & Mid(Label4.Caption, 9, 2)
End If
ReDim Preserve SavDat(i) As String
SavDat(i) = ReDat '记录处理之后的内容
i = i + 1
Loop
Close #1
Open App.Path & "\123.txt" For Output As #2 '打开文件
For j = 0 To i - 1
Print #2, SavDat(j) '循环保存已记录的内容
Next
Close #2
List1.AddItem Mid(Label4.Caption, 1, 4) & "." & Mid(Label4.Caption, 6, 2) & "." & Mid(Label4.Caption, 9, 2)
Label3.Caption = Label3.Caption + 1
End Sub
怎么改才能让最后ReDat的第2、3个逗号之间数+1,保存到123.txt
请高人指点,小弟表达能力不好,抱歉,附上说明哦~
Private Sub Command4_Click()
Dim ReDat As String '存读入的文字
Dim MidDat As String '第一个逗号前的内容
Dim SavDat() As String '处理之后的内容
Dim i As Variant '用作数组的下标,j同
Dim j As Variant
Open App.Path & "\123.txt" For Input As #1 '打开文件
Do While Not EOF(1) '循环读取到文件尾
Line Input #1, ReDat '读入一行
MidDat = Left(ReDat, InStr(1, ReDat, ",", vbTextCompare) - 1) '得到第一个逗号前的内容
If MidDat = Label1.Caption Then '如果与Label1.Caption的内容相匹配的一行,并在这一行后面加上:
ReDat = ReDat & "," & Mid(Label4.Caption, 3, 2) & Mid(Label4.Caption, 6, 2) & Mid(Label4.Caption, 9, 2)
End If
ReDim Preserve SavDat(i) As String
SavDat(i) = ReDat '记录处理之后的内容
i = i + 1
Loop
Close #1
Open App.Path & "\123.txt" For Output As #2 '打开文件
For j = 0 To i - 1
Print #2, SavDat(j) '循环保存已记录的内容
Next
Close #2
List1.AddItem Mid(Label4.Caption, 1, 4) & "." & Mid(Label4.Caption, 6, 2) & "." & Mid(Label4.Caption, 9, 2)
Label3.Caption = Label3.Caption + 1
End Sub
怎么改才能让最后ReDat的第2、3个逗号之间数+1,保存到123.txt
请高人指点,小弟表达能力不好,抱歉,附上说明哦~
