在VB中,如何将一组数据保存到TXT文本中?
展开全部
Private Sub Command1_Click()
Dim a(6) As Single
For i = 0 To UBound(a)
a(i) = i ^ 2
Next i
Open "c:\1.txt" For Output As #1
For i = 0 To UBound(a)
Print #1, a(i)
Next i
Close #1
Shell "notepad.exe c:\1.txt", vbNormalFocus
End Sub
Dim a(6) As Single
For i = 0 To UBound(a)
a(i) = i ^ 2
Next i
Open "c:\1.txt" For Output As #1
For i = 0 To UBound(a)
Print #1, a(i)
Next i
Close #1
Shell "notepad.exe c:\1.txt", vbNormalFocus
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
使用OpenTextFile,然后write
示例如下:
Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\testfile.txt", ForAppending,TristateFalse)
f.Write "Hello world!"
f.Close
End Sub
示例如下:
Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\testfile.txt", ForAppending,TristateFalse)
f.Write "Hello world!"
f.Close
End Sub
追问
如果给一个例子,
有十个数放在了fx()里,怎样将fx()里面的数保存成txt格式文本中啊?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有一个txt文件,里面内容既有数据又有文字,所有排成一列,但每三个是一组1,刘,0.1 2,李,0.3 你需要将什么内容保存出来就行。 ,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询