vb 读取文本文件

来源:百度知道 编辑:UC知道 时间:2024/06/25 09:32:51
如:如果D:/nxs/sxakn/xsmc(xsmc是txt文件)内容如下:

长的来说那是你来dcsdc
阿生产阿城ascas
是不安傻了长沙成了傻不傻dccasca
差价格拉茨sacacsanc

那么.......................
代码怎么写???????????????

Open "D:/nxs/sxakn/xsmc" for input as #1
While Not EOF(1)
Line Input #1,S
S1=S1 & S & IIf(Eof(1),"",vbCrlf)
Wend
Text1.Text=S1

'上面的代码将读取内容到文本框Text1中

Option Explicit
Dim txt As String
Private Sub Form_Load()
Open "D:/nxs/sxakn/xsmc.txt" For Input As #1
Input #1, txt
Close

Label1.Caption = txt
End Sub

显示在label1控件上面