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数据,上面的代码,只能显示文件名,却不能打开文件。望老师帮忙改一下 展开
保存:
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数据,上面的代码,只能显示文件名,却不能打开文件。望老师帮忙改一下 展开
1个回答
展开全部
'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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询