vb里面的对话框控件,打开“另存为”对话框后,单击取消选择不保存后还是会在目录保存文件
vb里面的对话框控件,打开“另存为”对话框后,单击取消选择不保存后还是会在目录保存文件。这个是怎么回事。可以点取消后不自动保存文件吗?而是用户点了保存才保存的Dialog...
vb里面的对话框控件,打开“另存为”对话框后,单击取消选择不保存后还是会在目录保存文件。这个是怎么回事。可以点取消后不自动保存文件吗?而是用户点了保存才保存的
Dialog.Flags = &H4
Dialog.DefaultExt = ".txt"
Dialog.FilterIndex = 1
Dialog.CancelError = False
Dialog.ShowSave
Open Dialog.FileName For Output As #1
Print #1, Text_List.Text
Close #1 展开
Dialog.Flags = &H4
Dialog.DefaultExt = ".txt"
Dialog.FilterIndex = 1
Dialog.CancelError = False
Dialog.ShowSave
Open Dialog.FileName For Output As #1
Print #1, Text_List.Text
Close #1 展开
3个回答
2013-04-17
展开全部
这个COM的对话框控件取消就是这样的机制,要判断用户点的是“取消”,就要设置控件的CancelError属性为True才可以接收到用户是否点了取消(这样真是增加了程序员的代码工作量),对了你的程序修改成这样就可以了:
On Error Resume Next
Dialog.Flags = &H4
Dialog.DefaultExt = ".txt"
Dialog.FilterIndex = 1
Dialog.CancelError = False
Dialog.ShowSave
If Err.Number = 0 Then
Open Dialog.FileName For Output As #1
Print #1, Text_List.Text
Close #1
End If 答案补充 有上的有误,下面的正确:
On Error Resume Next
Dialog.Flags = &H4
Dialog.DefaultExt = ".txt"
Dialog.FilterIndex = 1
Dialog.CancelError = True
Dialog.ShowSave
If Err.Number = 0 Then
Open Dialog.FileName For Output As #1
Print #1, Text_List.Text
Close #1
End If
On Error Resume Next
Dialog.Flags = &H4
Dialog.DefaultExt = ".txt"
Dialog.FilterIndex = 1
Dialog.CancelError = False
Dialog.ShowSave
If Err.Number = 0 Then
Open Dialog.FileName For Output As #1
Print #1, Text_List.Text
Close #1
End If 答案补充 有上的有误,下面的正确:
On Error Resume Next
Dialog.Flags = &H4
Dialog.DefaultExt = ".txt"
Dialog.FilterIndex = 1
Dialog.CancelError = True
Dialog.ShowSave
If Err.Number = 0 Then
Open Dialog.FileName For Output As #1
Print #1, Text_List.Text
Close #1
End If
2013-04-17
展开全部
Private Sub Command1_Click()
On Error GoTo ErrProc:
Dialog.Flags = &H4
Dialog.Filter = "*.txt"
Dialog.FilterIndex = 1
Dialog.CancelError = True
Dialog.ShowSave
Open "C:\Documents and Settings\11111\桌面\11.txt" For Output As #1
Print #1, Text1
Close #1
ErrProc:
End Sub 答案补充 Private Sub Command1_Click()
On Error GoTo ErrProc:
Dialog.Flags = &H4
Dialog.Filter = "*.txt"
Dialog.CancelError = True
Dialog.ShowSave
Open Dialog.FileName & ".txt" For Output As #1
Print #1, Text1
Close #1
ErrProc:
End Sub
On Error GoTo ErrProc:
Dialog.Flags = &H4
Dialog.Filter = "*.txt"
Dialog.FilterIndex = 1
Dialog.CancelError = True
Dialog.ShowSave
Open "C:\Documents and Settings\11111\桌面\11.txt" For Output As #1
Print #1, Text1
Close #1
ErrProc:
End Sub 答案补充 Private Sub Command1_Click()
On Error GoTo ErrProc:
Dialog.Flags = &H4
Dialog.Filter = "*.txt"
Dialog.CancelError = True
Dialog.ShowSave
Open Dialog.FileName & ".txt" For Output As #1
Print #1, Text1
Close #1
ErrProc:
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-04-17
展开全部
把CancelError设置为True当点取消时会产生一个错误 在程序开头加上On Error GoTo Wrong:
在程序最后写上Wrong:就可以了
在程序最后写上Wrong:就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询