VB创建文件夹与保存图片
PrivateSubCommand1_Click()DimrAsLongIfDir("D:\abc",vbDirectory)<>""ThenShell"cmd/c""r...
Private Sub Command1_Click()
Dim r As Long
If Dir("D:\abc", vbDirectory) <> "" Then
Shell "cmd /c""rmdir.exe /s /q D:\abc\""", vbNormalFocus
MkDir "D:\abc"
keybd_event VK_SNAPSHOT, 1, 0, 0
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), "D:\abc\123.bmp "
MsgBox "保存成功!", vbInformation + vbOKOnly, "提示"
r = ShellExecute(0, "open", "D:\abc", 0, 0, 1)
Else
MkDir "D:\abc"
keybd_event VK_SNAPSHOT, 1, 0, 0
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), "D:\abc\123.bmp "
MsgBox "保存成功!", vbInformation + vbOKOnly, "提示"
r = ShellExecute(0, "open", "D:\abc", 0, 0, 1)
End If
End Sub
请问错在哪里了,怎么改。
还有帮忙简化下。
MkDir "D:\abc"
路径\文件访问错误 展开
Dim r As Long
If Dir("D:\abc", vbDirectory) <> "" Then
Shell "cmd /c""rmdir.exe /s /q D:\abc\""", vbNormalFocus
MkDir "D:\abc"
keybd_event VK_SNAPSHOT, 1, 0, 0
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), "D:\abc\123.bmp "
MsgBox "保存成功!", vbInformation + vbOKOnly, "提示"
r = ShellExecute(0, "open", "D:\abc", 0, 0, 1)
Else
MkDir "D:\abc"
keybd_event VK_SNAPSHOT, 1, 0, 0
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), "D:\abc\123.bmp "
MsgBox "保存成功!", vbInformation + vbOKOnly, "提示"
r = ShellExecute(0, "open", "D:\abc", 0, 0, 1)
End If
End Sub
请问错在哪里了,怎么改。
还有帮忙简化下。
MkDir "D:\abc"
路径\文件访问错误 展开
展开全部
Private Const VK_SNAPSHOT = &H2C
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
没有声明而已,把以上代码加入通用声明里即可
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
没有声明而已,把以上代码加入通用声明里即可
更多追问追答
追问
这个代码我有
追答
在按钮事件中加入下面语句,加在第一行
On Error Resume Next
百事牛
2024-10-22 广告
2024-10-22 广告
百事牛是共享提供商,我们提供可靠有效的服务,适当合理的授权费有利于的继续更新优化。同样的事情,同样的方法,百事牛团队十年磨一剑,始终至聚焦在密码恢复领域,深耕于此,我们已研制出有别于其他公司的算法和运算模式, 百事牛的暴力模式加入了分布式点...
点击进入详情页
本回答由百事牛提供
展开全部
把你的代码拷贝到我的VB上运行,错误行为
keybd_event VK_SNAPSHOT, 1, 0, 0
错误类型:子程序或函数未定义
keybd_event VK_SNAPSHOT, 1, 0, 0
错误类型:子程序或函数未定义
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
MkDir "D:\abc"
路径\文件访问错误
原因在于:d:\abc文件夹已经存在!
你可以加一个判断,如果文件夹不存在,则创建!代码如下!
If Dir("d:\abc", vbDirectory) = "" Then MkDir "D:\abc"
路径\文件访问错误
原因在于:d:\abc文件夹已经存在!
你可以加一个判断,如果文件夹不存在,则创建!代码如下!
If Dir("d:\abc", vbDirectory) = "" Then MkDir "D:\abc"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
错在哪一行你不肯说
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
LZ,请说明错误提示,及出错行数!
追问
第一个MkDir "D:\abc"
路径\文件访问错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询