文本文件内容:
111
222
333
#下面不读入
444
555
666
777
#上面的不读入
888
999
000用Open "aaa.txt" For Output As #1
按顺序读到text(i).text 文本框内 即
text1.text= 111 (指窗体上显示的值)
text2.text= 222 (指窗体上显示的值)
text3.text= 333 (指窗体上显示的值)
text4.text= 888 (指窗体上显示的值)
text5.text= 999 (指窗体上显示的值)
text6.text= 000 (指窗体上显示的值)
Close #1要求两个有#的行中间的内容读入到combobox里去 即,444,555,666,777会被additem为combo1里.请问这个如何解决
111
222
333
#下面不读入
444
555
666
777
#上面的不读入
888
999
000用Open "aaa.txt" For Output As #1
按顺序读到text(i).text 文本框内 即
text1.text= 111 (指窗体上显示的值)
text2.text= 222 (指窗体上显示的值)
text3.text= 333 (指窗体上显示的值)
text4.text= 888 (指窗体上显示的值)
text5.text= 999 (指窗体上显示的值)
text6.text= 000 (指窗体上显示的值)
Close #1要求两个有#的行中间的内容读入到combobox里去 即,444,555,666,777会被additem为combo1里.请问这个如何解决
解决方案 »
- 大家在使用vb编辑器当中是如何解决这个问题的啊?
- 请教各位:VB如何实现矩阵计算,比如,矩阵转置、相乘,求秩等基本运算,谢谢了!
- 关于在数据库查询时使用SQL语句的问题
- 这么长的语句怎么弄啊?
- 600分问题:结贴了!没有得分的请进!
- 有哪位大侠对语音聊天控件熟悉的,我想了解一下语聊控件
- 请问如何使用datareport实现按要求打印啊??谢谢了!急
- 哪里可以得到Microsoft WMI Scripting Library
- 请问,在vb下如何调用运行一个在SQL下已编好的.sql文件
- 大家帮忙看一下这个delphi的 dll
- 对datagrid控件的某一列进行求和在一个文本框里显示(急用)
- 简单的ListView vb6.0
给个代码什么的,偶还处于VB入门型的,讲的太深奥,偶听不太懂啊
dim h as long
dim i as long,idx as long
dim tmp
dim b as boolean'一次性读出文本内容到变量s中:
h=freefile
open app.path &"\aaa.txt" for binary as h
s=space(lof(h))
get #h,,s
close'按回车符分组处理
tmp=split(s,vbcrlf)
for i=0 to ubound(tmp)
if trim(tmp(i))<>"" and left(tmp(i),1)<>"#" then
if b=false then
text1(idx)=tmp(i)
idx =idx+1
else
combo1.additem tmp(i)
end if
elseif left(tmp(i),1)="#" then
b=not b
end if
next
大概最直接的思路就是这样,没测试
hFile = freefile()
open "..." for input access read as #hfile
while not eof(hfile)
line input Ehfile, sLine
if left(sline,1) = "#" then
bFlag = Not bFlag
else
if bFlag then combo1.additem sLine
end if
wend
close #hfile
dim flag1 as boolean
dim i as longOpen "aaa.txt" For Output As #1
i=1
flag1=false
Do While Not EOF(1)
Line Input #1, Strtmp
if Strtmp="#" then
if flag1=false then
flag1=true
else
flag1=false
end if
else
if flag1=false then
text(i).text=Strtmp
end if
end if
Loop
dim flag1 as boolean
dim i as long Open "aaa.txt" For Output As #1
i=1
flag1=false
Do While Not EOF(1)
Line Input #1, Strtmp
if Strtmp="#" then
if flag1=false then
flag1=true
else
flag1=false
end if
else
if flag1=false then
text(i).text=Strtmp
i=i+1
end if
end if
Loop