大唐双龙记粤语百度云:vb写入txt文件多行

来源:百度文库 编辑:高校问答 时间:2024/04/28 18:33:35
一个文本框:输入打印的行数
一个按扭"生成便保存"

如 在文本框输入 4
按按扭后产生

*
**
***
****
之后把结果保存在 output.txt 文件中

Option Explicit

Private Sub Command1_Click()
Dim l As Integer
l = Text1.Text
Dim i As Integer, j As Integer
Open "c:\output.txt" For Output As 1
For i = 1 To l Step 1
For j = 1 To i Step 1
Print #1, "*";
Next j
Print #1, vbCrLf
Next i
Close
End Sub

Private Sub Command1_Click()
For i = 1 To Val(Text1.Text)
tmp = tmp & String(i, "*") & vbCrLf
Next i
Print tmp
Open App.Path & "\output.txt" For Append As #1
Print #1, tmp
Close #1
End Sub

Private Sub Command1_Click()
Dim a As Integer
a = Text1.Text
Dim a As Integer, b As Integer
Open "c:\output.txt" For Output As 1
For a = 1 To a Step 1
For b= 1 To a Step 1
Print #1, "*";
Next j
Print #1, vbCrLf
Next i
Close
End Sub