Dim c1
Dim newstring
newstring = "dsfdsfjldsjlfdsjlj"
Open newstring For Input As #1
Do While Not EOF(1)
Line Input #1, c1
Text1.Text = Text1.Text & c1
Loop
Close #1
为什么他只提示找不到文件,难道不能把NEWSTRING变量直接替换掉路径吗?我想实现的效果就是让OPEN直接读取NEWSTRING变量里的内容按行读取需要怎样写?
Dim newstring
newstring = "dsfdsfjldsjlfdsjlj"
Open newstring For Input As #1
Do While Not EOF(1)
Line Input #1, c1
Text1.Text = Text1.Text & c1
Loop
Close #1
为什么他只提示找不到文件,难道不能把NEWSTRING变量直接替换掉路径吗?我想实现的效果就是让OPEN直接读取NEWSTRING变量里的内容按行读取需要怎样写?
Dim newstring as stringnewstring = "c:\abc.txt"Open newstring For Input As #1
Do While Not EOF(1)
Line Input #1, c1
Text1.Text = Text1.Text & c1
Loop
Close #1
保证这个路径有意义
文本文件里的内容已存入了变量newstring ,为什么还要读取??你要从哪读取?
line input和 input只能从文件中读取!
“放在网络上的程序”,是在网络主机运行吧!
“了避免网络主机关机后,而客户端机器继续调用网络主机上的文件!这样直接调内存来完成就不会出错了”这一句真是太幽默了,哈哈!
:NEWSTRING 里的内容为: abcsdfsdlfjdslfjdsljd
dsjlfdsljfjdsljfldsjfl
sdfjldsjfldsjfldsjflds
但是我把那个本该写路径的换成变量NEWSTRING就不能用了,我要达到的效果就是
Open newstring For Input As #1
Do While Not EOF(1)
Line Input #1, c1
Text1.Text = Text1.Text & c1
Loop
Close #1
不知道错在哪里了?如果有其他方法实现也行!
看你这句的意思,不知道你为什么还是没看明白,我在程序加载时,把需要从服务器调用的文件内容如a.txt放入变量NEWSTRING,这样在程序已经运行中,就可以直接调newstring就不需要调用服务器的文件了不就不会出错了吗
Dim newstring as stringnewstring = "c:\abc.txt" '""中的是路径就行了Open newstring For Input As #1
Do While Not EOF(1)
Line Input #1, c1
Text1.Text = Text1.Text & c1
Loop
Close #1
Open newstring For Input As #1
是读取文件的方法读变量直接 text1.text=newstring 不就结了没看明白
是读取文件的方法读变量直接 text1.text=newstring 不就结了没看明白
===========同意
因为要对变量里的内容按行读取操作,然后我程序要塞选需要的内容,不是把整个读下来
因为要对变量里的内容按行读取操作,然后我程序要塞选需要的内容,不是把整个读下来
----------------
确保你由文件读入变量时,行与行之间用了分隔符(比如回车vbcrlf),然后用split函数处理比如:
newstring = "aaaaaaaa"& vbcrlf & "bbbbbbbbbbbbbbb"
dim s() as string
s=xplit(newstring,vbcrlf)
这样
s(0)="aaaaaaaa"
s(1)="bbbbbbbbbbbbbbb"
因为要对变量里的内容按行读取操作,然后我程序要塞选需要的内容,不是把整个读下来
----------------
确保你由文件读入变量时,行与行之间用了分隔符(比如回车vbcrlf),然后用split函数处理比如:
newstring = "aaaaaaaa"& vbcrlf & "bbbbbbbbbbbbbbb"
dim s() as string
s=split(newstring,vbcrlf)
这样
s(0)="aaaaaaaa"
s(1)="bbbbbbbbbbbbbbb"
Do While Not EOF(1)
Line Input #1, c1
Loop
for i=0 to ubound(s)
print s(i)
next