vb Microsoft common dialog control 6.0 的问题

以下两个代码是保存和导入两个代码保存:PrivateSubCommand46_Click()Screen.MousePointer=vbHourglassDimiAsIn... 以下两个代码是保存和导入两个代码
保存:
Private Sub Command46_Click()

Screen.MousePointer = vbHourglass

Dim i As Integer
Dim j As Integer
CommonDialog1.Filter = "CSV File|*.txt"
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
If Dir(CommonDialog1.FileName) <> vbNullString Then
If MsgBox("原文件存在,是否覆盖?", vbYesNo, "提示框") = vbYes Then
Kill CommonDialog1.FileName
Else
Exit Sub
End If
End If

Open CommonDialog1.FileName For Output As #1
For i = 0 To 200
For j = 0 To 3
Print #1, MSHFlexGrid1.TextMatrix(i, j) & ",";
Next
Print #1, vbNullString
Next
Close #1
End If
Screen.MousePointer = vbDefault
End Sub
打开:
Private Sub Command46_Click()
Dim inputdata As String
CommonDialog1.Action = 1
File = CommonDialog1.FileName
If File = "" Then
MsgBox "没有选择文件!", vbOKOnly, "文件选择"
Text1.SetFocus
Exit Sub
Else
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, inputdata
Text1.Text = Text1.Text + inputdata + vbCrLf
Loop
Close #1
End If
End Sub
保存的----我想保存list1里的数据,保存格式.txt该如何改
打开的----想在list1里打开本程序中的一些txt数据,上面的代码,只能显示文件名,却不能打开文件。望老师帮忙改一下
展开
 我来答
43295811
2008-08-23 · TA获得超过1529个赞
知道大有可为答主
回答量:1701
采纳率:0%
帮助的人:2038万
展开全部
'CommonDialog1.FilterIndex = 1

Private Sub Command46_Click()

Screen.MousePointer = vbHourglass

Dim i As Integer
Dim j As Integer
CommonDialog1.Filter = "CSV File|*.txt"
CommonDialog1.DefaultExt = "txt"
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
If Dir(CommonDialog1.FileName) <> vbNullString Then
If MsgBox("原文件存在,是否覆盖?", vbYesNo, "提示框") = vbYes Then
Kill CommonDialog1.FileName
Else
Exit Sub
End If
End If

Open CommonDialog1.FileName For Output As #1
For i = 0 To 200
For j = 0 To 3
Print #1, MSHFlexGrid1.TextMatrix(i, j) & ",";
Next
Print #1, vbNullString
Next
Close #1
End If
Screen.MousePointer = vbDefault
End Sub
打开:
Private Sub Command46_Click()
Dim inputdata As String
CommonDialog1.Action = 1
File = CommonDialog1.FileName
If File = "" Then
MsgBox "没有选择文件!", vbOKOnly, "文件选择"
Text1.SetFocus
Exit Sub
Else
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, inputdata
list1.additem inputdata'你的数据要按行保存,不然出错
Loop
Close #1
End If
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式