您的位置:程序门 -> vb -> 基础类



文件写入问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


文件写入问题[已结贴,结贴人:fighter222]
发表于:2008-01-17 13:20:07 楼主
我想把产生的一组随机数写入text文本,可是我这么写只能写入最后一个数,如果要写入一组数应该怎么写啊(每写一个数就转下一行再写)
private   sub   command1_click()
command1.visible   =   false
randomize   timer
while   j   <   10
q   =   int(rnd(1)   *   369   +   1)
label1.caption   =   q:   doevents
if   n(q)   =   0   and   bstop   =   true   then
open   "c:\vb.txt"   for   output   as   #1
print   #1,   q
close   #1
n(q)   =   1
j   =   j   +   1
bstop   =   false
end   if
wend
end   sub
发表于:2008-01-17 13:29:151楼 得分:0
put       #1,   ,   q  
发表于:2008-01-17 13:34:182楼 得分:0
vb.net code
private sub command1_click() command1.visible = false randomize timer open "c:\vb.txt" for output as #1 while j < 10 q = intrnd1) * 369 + 1) label1.caption = q: doevents if n(q) = 0 and bstop = true then print #1, q n(q) = 1 j = j + 1 bstop = false end if wend close #1 end sub
发表于:2008-01-17 13:36:053楼 得分:20
vb.net code
private sub command1_click() dim str as string command1.visible = false randomize timer str = "" open "c:\vb.txt" for output as #1 while j < 10 q = intrnd1) * 369 + 1) label1.caption = q: doevents if n(q) = 0 and bstop = true then str = str & q & chr13) & chr10) n(q) = 1 j = j + 1 bstop = false end if wend if str <> "" then print #1, str end if close #1 end sub
发表于:2008-01-17 13:36:364楼 得分:0
用3楼那个
发表于:2008-01-17 14:00:275楼 得分:0
谢谢乐,结贴


快速检索

最新资讯
热门点击