VB怎样把文本文档里的不同段落的文字读取到不同的文本框中?
我关闭程序保存时的代码是:PrivateSubForm_Unload(CancelAsInteger)Open"D:\YY.txt"ForOutputAs#1Print#...
我关闭程序保存时的代码是:
Private Sub Form_Unload(Cancel As Integer)
Open "D:\YY.txt" For Output As #1
Print #1, TextBox1.Text
Print #1, TextBox2.Text
Print #1, TextBox3.Text
Print #1, TextBox4.Text
Print #1, TextBox5.Text
Print #1, TextBox6.Text
Close #1
End Sub
这样就在同一个文本文档(.txt)中保存了6个段落,我现在想在打开程序时分别读取回对应的文本框
简单说就是起到一个保存的作用,在打开时可以看到保存的内容。 展开
Private Sub Form_Unload(Cancel As Integer)
Open "D:\YY.txt" For Output As #1
Print #1, TextBox1.Text
Print #1, TextBox2.Text
Print #1, TextBox3.Text
Print #1, TextBox4.Text
Print #1, TextBox5.Text
Print #1, TextBox6.Text
Close #1
End Sub
这样就在同一个文本文档(.txt)中保存了6个段落,我现在想在打开程序时分别读取回对应的文本框
简单说就是起到一个保存的作用,在打开时可以看到保存的内容。 展开
3个回答
展开全部
Private Sub Form_Load()
Dim I As Integer, S As String
Open "D:\YY.txt" For Input As #1
Do While Not EOF(1)
I = I + 1
Line Input #1, S
Me.Controls("Text" & CStr(I)).Text = S
Loop
Close 1
End Sub
Dim I As Integer, S As String
Open "D:\YY.txt" For Input As #1
Do While Not EOF(1)
I = I + 1
Line Input #1, S
Me.Controls("Text" & CStr(I)).Text = S
Loop
Close 1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
If Dir("D:\YY.txt") = "" Then Exit Sub
Open "D:\YY.txt" For Input As #1
Line Input #1, a
Line Input #1, b
Line Input #1, c
Line Input #1, d
Line Input #1, e
Line Input #1, f
Close #1
Text1.Text = a
Text2.Text = b
Text3.Text = c
Text4.Text = d
Text5.Text = e
Text6.Text = f
End Sub
If Dir("D:\YY.txt") = "" Then Exit Sub
Open "D:\YY.txt" For Input As #1
Line Input #1, a
Line Input #1, b
Line Input #1, c
Line Input #1, d
Line Input #1, e
Line Input #1, f
Close #1
Text1.Text = a
Text2.Text = b
Text3.Text = c
Text4.Text = d
Text5.Text = e
Text6.Text = f
End Sub
追问
这个a~f是赋值吧?
追答
是啊,先取出,后赋值
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
Open "D:\YY.txt" For Input As #1
Line Input #1, TextBox1.Text
Line Input #1, TextBox2.Text
Line Input #1, TextBox3.Text
Line Input #1, TextBox4.Text
Line Input #1, TextBox5.Text
Line Input #1, TextBox6.Text
Close #1
End Sub
Open "D:\YY.txt" For Input As #1
Line Input #1, TextBox1.Text
Line Input #1, TextBox2.Text
Line Input #1, TextBox3.Text
Line Input #1, TextBox4.Text
Line Input #1, TextBox5.Text
Line Input #1, TextBox6.Text
Close #1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询