VB点击按钮1次,读取文本1行,点击第2次,读取第2行,依次往下.... ... 直到全部读完。
VB点击按钮1次,读取txt文件内容第1行,点击第2次,读取第2行,依次往下......全部读取完后提示结束!(前提不知道文本有多少行,每行的字符个数不一样,有换行符))...
VB点击按钮1次,读取txt文件内容第1行,点击第2次,读取第2行,依次往下... ...全部读取完后提示结束! (前提不知道文本有多少行,每行的字符个数不一样,有换行符)),每次点击按钮读取时通过text1显示第几条,读取的内容通过text2显示出来并同时送剪贴板。能否提供详细源代码,
展开
1个回答
展开全部
Dim text As String
Dim i As Integer
Dim a() As String
Private Sub Command1_Click()
text = ""
CommonDialog1.FileName = ""
CommonDialog1.Filter = "文本文件.txt|*.txt"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, demo
text = text & vbCrLf & demo
Loop
End If
Close #1
End Sub
Private Sub Command2_Click()
a = Split(text, vbCrLf)
If i < UBound(a) Then
Text1.text = i + 1
Text2.text = a(i + 1)
Clipboard.Clear
Clipboard.SetText (Text2.text)
i = i + 1
End If
End Sub
Dim i As Integer
Dim a() As String
Private Sub Command1_Click()
text = ""
CommonDialog1.FileName = ""
CommonDialog1.Filter = "文本文件.txt|*.txt"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, demo
text = text & vbCrLf & demo
Loop
End If
Close #1
End Sub
Private Sub Command2_Click()
a = Split(text, vbCrLf)
If i < UBound(a) Then
Text1.text = i + 1
Text2.text = a(i + 1)
Clipboard.Clear
Clipboard.SetText (Text2.text)
i = i + 1
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询