求助VB编程问题 将TXT中的数据写入数组中
如图所示的TXT文件,要求将这些数据写入到一个数组中s(1)=0s(2)=0s(3)…………求大神指点!...
如图所示的TXT文件,要求将这些数据写入到一个数组中s(1)=0 s(2)=0 s(3)………… 求大神指点!
展开
1个回答
展开全部
Dim a(5) As Double
Private Sub Command1_Click()
strfile = ""
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowSave
If CommonDialog1.CancelError = True Then Exit Sub
If CommonDialog1.FileName = "" Then Exit Sub
Open CommonDialog1.FileName For Output As #1
For i = 0 To 4
strfile = strfile & a(i) & vbCrLf
Next i
Print #1, strfile
Close
MsgBox "Export Sucessfully!"
Shell "notepad.exe " & CommonDialog1.FileName, vbNormalFocus
End Sub
Private Sub Form_Load()
a(0) = 1
a(1) = 2
a(2) = 3
a(3) = 4
a(4) = 5
End Sub
=================
添加一个commomdialog控件,这里对数组的初始化由你自己去写,这里只是参考
Private Sub Command1_Click()
strfile = ""
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowSave
If CommonDialog1.CancelError = True Then Exit Sub
If CommonDialog1.FileName = "" Then Exit Sub
Open CommonDialog1.FileName For Output As #1
For i = 0 To 4
strfile = strfile & a(i) & vbCrLf
Next i
Print #1, strfile
Close
MsgBox "Export Sucessfully!"
Shell "notepad.exe " & CommonDialog1.FileName, vbNormalFocus
End Sub
Private Sub Form_Load()
a(0) = 1
a(1) = 2
a(2) = 3
a(3) = 4
a(4) = 5
End Sub
=================
添加一个commomdialog控件,这里对数组的初始化由你自己去写,这里只是参考
追问
能认真的回答问题么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询