前端之家收集整理的这篇文章主要介绍了
vb备份代码,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Private Sub munSJBF_Click()
On Error GoTo ERR_line
newname = App.Path & "/data/data.cc"
datapath = App.Path & "/backup/" & Date & " 备份卡.bak"
FileCopy newname,datapath
MsgBox "数据已备份到 " & datapath,64,"提示"
Exit Sub
ERR_line:
MsgBox "不能完成数据备份!",48,"运行错误"
End Sub
Private Sub munSJHY_Click()
On Error GoTo ERR_line
Me.CommonDialog1.ShowSave
snewname = Me.CommonDialog1.FileName
sdatapath = App.Path & "/data/data.cc"
If snewname <> "" Then
If MsgBox("还原后将覆盖原有数据,确定还原吗?",vbInformation + vbYesNo,"提示") = vbYes Then
FileCopy sdatapath,snewname ’
MsgBox "数据已经成功还原!请重新登陆 ","提示"
Unload Me
frmLogin.Show
Else
Exit Sub
End If
End If
Exit Sub
ERR_line:
MsgBox "不能完成数据还原,请进入系统后未做任何操作时进行!","运行错误"
End Sub
data backup 确保这个文件夹存在
先用 if dir("文件夹路径",vbDirectory)<> then 判断下
原文链接:https://www.f2er.com/vb/261293.html