一个VB的编程问题。很简单的。

来源:百度知道 编辑:UC知道 时间:2024/06/30 14:51:22
path = "D:\新建文件夹\记事本\1.txt"
Plugin fileHandle=File.OpenFile(path)
Plugin file20byte=File.ReadFile(fileHandle,20)
a=file20byte
SayString a

这是一个提取1.txt的首行。我想做一个循环,分次提取下一行下一行

能不能帮帮忙!

Dim allcmd As String
Dim cmd As String
Dim path As String

Private Sub Command3_Click()
path = "D:\新建文件夹\记事本\1.txt"
Open path For Input As #1
Do While Not EOF(1)
Line Input #1, cmd
allcmd = allcmd & cmd & vbCrLf
Loop
Close #1
Text1.Text = allcmd
End Sub

添加一个按钮

添加一个文本框,并且设置multiline的属性为true

就可以看到效果!!!!

path = "D:\新建文件夹\记事本\1.txt"
Plugin fileHandle=File.OpenFile(path)
Plugin file20byte=File.ReadFile(fileHandle,20)

do while file20byte<>""
a=file20byte
SayString a
Plugin file20byte=File.ReadFile(fileHandle,20)
loop

Dim allcmd As String
Dim cmd As String
dim path as string
path = "D:\新建文件夹\记事本\1.txt"
Open path For Input As #1
Do While Not EOF(1)
Line Input #1, cmd
allcmd = allcmd