文件写入问题

fighter222 2008-01-17 01: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
...全文
24 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
fighter222 2008-01-17
谢谢乐,结贴
回复
白发程序猿 2008-01-17
用3楼那个
回复
白发程序猿 2008-01-17
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 = Int(Rnd(1) * 369 + 1)
Label1.Caption = q: DoEvents
If n(q) = 0 And bStop = True Then
str = str & q & Chr(13) & Chr(10)
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

Private Sub Command1_Click()
Command1.Visible = False
Randomize Timer
Open "c:\vb.txt" For Output As #1
While j < 10
q = Int(Rnd(1) * 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
回复
jjfwenwenti 2008-01-17
put #1, , q
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7453

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告