求VB大神此代码出错的原因,以及应该怎么修改
PrivateDeclareFunctionSetWindowPos&Lib"user32"(ByValhwndAsLong,_ByValhWndInsertAfterA...
Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Dim a As Integer
Dim xx As Long, yy As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X
yy = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Me.Move Me.Left + X - xx, Me.Top + Y - yy
End Sub
Private Sub Form_Load()
Set fs = CreateObject("Scripting.FileSystemObject")
f = "d:\" & "\" & Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日"
If fs.FolderExists(f) Then
MsgBox "文件夹已存在"
Else
fs.CreateFolder f
End If
App.TaskVisible = False
Timer1.Interval = 1000
a = 1
End Sub
Private Sub Label4_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
End Sub
Private Sub Label5_Click()
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
End Sub
Private Sub Label6_Click()
End
End Sub
Private Sub Label7_Click()
Shell "cmd.exe /c copy /y ""d:\数据库\sjk.dat"" G:\数据库备份\" & Label1.Caption & ".dat", vbHide
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Format(Now, "YYYY年MM月DD号hh点mm分ss秒")
End Sub
Private Sub Timer2_Timer()
a = a + 1
Label2.Caption = a
If Label2.Caption = 10 Then
a = 0
Shell "cmd.exe /c copy /y ""d:\数据库\sjk.dat", f & Label1.Caption & ".dat", vbHide
End If
End Sub
Private Sub Timer3_Timer()
myval = SetWindowPos(Form1.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
------------------------------------------------------------------------------------------------------------------------
Shell "cmd.exe /c copy /y ""d:\数据库\sjk.dat", f & Label1.Caption & ".dat", vbHide
此行代码出错 展开
ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Dim a As Integer
Dim xx As Long, yy As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X
yy = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Me.Move Me.Left + X - xx, Me.Top + Y - yy
End Sub
Private Sub Form_Load()
Set fs = CreateObject("Scripting.FileSystemObject")
f = "d:\" & "\" & Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日"
If fs.FolderExists(f) Then
MsgBox "文件夹已存在"
Else
fs.CreateFolder f
End If
App.TaskVisible = False
Timer1.Interval = 1000
a = 1
End Sub
Private Sub Label4_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
End Sub
Private Sub Label5_Click()
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
End Sub
Private Sub Label6_Click()
End
End Sub
Private Sub Label7_Click()
Shell "cmd.exe /c copy /y ""d:\数据库\sjk.dat"" G:\数据库备份\" & Label1.Caption & ".dat", vbHide
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Format(Now, "YYYY年MM月DD号hh点mm分ss秒")
End Sub
Private Sub Timer2_Timer()
a = a + 1
Label2.Caption = a
If Label2.Caption = 10 Then
a = 0
Shell "cmd.exe /c copy /y ""d:\数据库\sjk.dat", f & Label1.Caption & ".dat", vbHide
End If
End Sub
Private Sub Timer3_Timer()
myval = SetWindowPos(Form1.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
------------------------------------------------------------------------------------------------------------------------
Shell "cmd.exe /c copy /y ""d:\数据库\sjk.dat", f & Label1.Caption & ".dat", vbHide
此行代码出错 展开
3个回答
展开全部
可能是Label1中含有空格
建议修改如此:
Private Sub Label7_Click()
Dim strCmd As String
strCmd = "cmd.exe /c copy /y ""d:\数据库\sjk.dat"" ""G:\数据库备份\" & Label7.Caption & ".dat"""
'MsgBox strCmd
Shell strCmd, vbHide
End Sub
追问
Shell "cmd.exe /c copy /y ""d:\数据库\sjk.dat", f & Label1.Caption & ".dat", vbHide
主要是此行代码出错
其中的f是创建日期文件后将sjk.dat使用cmd命令复制到f的文件里面
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Shell "cmd.exe /c copy /y d:\数据库\sjk.dat, “ & f & Label1.Caption & ".dat", vbHide
试试...不然可能是 label 出问题了
试试...不然可能是 label 出问题了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询