海南人民网视窗:VB OPEN语句
来源:百度文库 编辑:神马品牌网 时间:2024/10/06 02:42:32
使用 open 语句用来加载 文本文件内容
Private Sub Command1_Click()
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Dim a As String
Open CommonDialog1.FileName For Input As #1
Input #1, a
Text1.Text = a
Close #1
End Sub
为什么只加载一行
Private Sub Command1_Click()
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Dim a As String
Open CommonDialog1.FileName For Input As #1
Input #1, a
Text1.Text = a
Close #1
End Sub
为什么只加载一行
设置text的Multiline属性为true
用Line Input做
Private Sub Command1_Click()
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Dim a As String
Open CommonDialog1.FileName For Input As #1
do while not eof(1)
Line Input #1, a
Text1.Text =Text1.Text + a + vbCrLf
loop
Close #1
End Sub
搞定~
因为input #1,a 指针未下移
初学时常犯
具体怎么改还是自己该吧
Open CommonDialog1.FileName For Input As #1
Text1.Text = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1