VB,怎么把一个文本文件aaa.txt中所有的内容读到文本框中,请写出详细的代码.

来源:百度知道 编辑:UC知道 时间:2024/04/27 21:36:17

public function loadtext(madd as string) as string
dim strA as string
dim strB as string
open madd for input as #1
while Eof(1)
Get #1,,strA
strB=strB & starA
wend
loadtext=strB
end function

在程序中调用此函数即可,如:text1.text=loadtext("c:\aaa.txt")

首先用读语句将文本文件的内容读入变量A$中,然后让文本框.text=A$即可。

Text1.Text = ""
Open "文件名" For Input As #1
Text1.SelText = StrConv(InputB(LOF(1), #1), vbUnicode)
Close #1