我的工程里面使用了CommonDialog用来存放文件的,但是在运行的时候会发现老是报错,报的是:Path/File access error.
我存放文件的程序是:
Public Sub SaveData() If Not Success Then
MsgBox "通讯失败"
Exit Sub
Else
Dim mfile As String
Dim hour2 As Integer
Dim minute2 As Integer
'---使用通用对话框,控件名就是CommonDialog-----
Form1.CommonDialog.Filter = "txt file|*.txt"
Form1.CommonDialog.ShowSave
mfile = Form1.CommonDialog.FileName
'-----存成文本文件---
Open mfile For Append As #1
Write #1, "日期", "时间", "数据"
For i = 1 To Data_Len
hour2 = i \ 4
minute2 = (i Mod 4) * 15
' Write #1, month2, date2, hour2, minute2, Data(i)
Print #1, month2 & "\";
Print #1, date2 & Space(2);
Print #1, hour2 & ":";
Print #1, minute2 & Space(4);
Print #1, Data(i)
Next i
Close End If
End Sub
谢谢谢谢
我存放文件的程序是:
Public Sub SaveData() If Not Success Then
MsgBox "通讯失败"
Exit Sub
Else
Dim mfile As String
Dim hour2 As Integer
Dim minute2 As Integer
'---使用通用对话框,控件名就是CommonDialog-----
Form1.CommonDialog.Filter = "txt file|*.txt"
Form1.CommonDialog.ShowSave
mfile = Form1.CommonDialog.FileName
'-----存成文本文件---
Open mfile For Append As #1
Write #1, "日期", "时间", "数据"
For i = 1 To Data_Len
hour2 = i \ 4
minute2 = (i Mod 4) * 15
' Write #1, month2, date2, hour2, minute2, Data(i)
Print #1, month2 & "\";
Print #1, date2 & Space(2);
Print #1, hour2 & ":";
Print #1, minute2 & Space(4);
Print #1, Data(i)
Next i
Close End If
End Sub
谢谢谢谢
解决方案 »
- VB pictureBox 对线条的 放大
- 将数张图象文件转换成二进制文件进行比对(求助)
- 为什么我在xp vb6.0下开发的软件,用setup factory7打包。在win98下不能安装
- SQL 语句 - 请帮助
- 本公司招聘VB开发人员(北京)
- 水晶报表的.rpt文件内嵌的数据库路径能用控件动态修改吗?
- 急,怎样用VB编程实现注册控件
- 如何将文件存入缓冲区,实现堆栈?
- LINUX是什么啊,还有UNIX,他们和编程有关系吗?有买他们的软件吗DELPHI好学吗?
- 用VB是否可以监视打印机的状态(是否处于打印)
- 请问谁有复杂验证码程序?
- 求助一个很简单的设置font size问题,拜托高手们看下
'你在打开文件前,必须先判断文件是否存在,即:dir(mfile)<>"",才进行下步操作。
'关于CancelError参考回帖:http://community.csdn.net/Expert/topic/4453/4453456.xml?temp=.8662989
就打开文件.
或者是CancelError设为True,在ShowSave前添加On Error Goto ...,在错误处理段,你在处理.
参考回帖:
http://community.csdn.net/Expert/topic/4453/4453456.xml?temp=.8662989