注册 登录
编程论坛 VB6论坛

又遇到问题了,麻烦大神来看看

VB丶小宇 发布于 2013-03-22 19:05, 399 次点击
我用VB写了一个图片浏览器程序,但遇到了问题,请看一下代码:
Option Explicit

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dim r As VbMsgBoxResult
On Error GoTo eh
Dir1.Path = Drive1.Drive
Exit Sub
eh:
If Err.Number = 68 Then
r = MsgBox("请插入磁盘!", vbRetryCancel + vbCritical, "缺少磁盘!")
If r = vbRetry Then
Resume
Else
Drive1.Drive = "c:"
Resume Next
End If
End Sub
Private Sub File1_Click()
If Option2.Value = True Then Exit Sub
Dim picfile As String
If Right(Dir1.Path, 1) = "\" Then
picfile = Dir1.Path + File1.FileName
Else
picfile = Dir1.Path + "\" + File1.FileName
End If
Image1.Picture = LoadPicture(picfile)
Text1.Text = File1.FileName
End Sub

Private Sub File1_DblClick()
If Option1.Value = True Then Exit Sub
Dim picfile As String
If Right(Dir1.Path, 1) = "\" Then
picfile = Dir1.Path + "\" + File1.FileName
End If
Image1.Picture = LoadPicture(picfile)
Text1.Text = File1.FileName
End Sub
程序运行没问题,但如果从
只有本站会员才能查看附件,请 登录
换到
只有本站会员才能查看附件,请 登录
d就会出现
只有本站会员才能查看附件,请 登录
错误,求大神解决。
2 回复
#2
seafish0112013-03-22 20:22
Private Sub Drive1_Change()
Dim r As VbMsgBoxResult
On Error GoTo eh
Dir1.Path = Drive1.Drive
Exit Sub
eh:
If Err.Number = 68 Then
r = MsgBox("请插入磁盘!", vbRetryCancel + vbCritical, "缺少磁盘!")
If r = vbRetry Then
Resume
Else
Drive1.Drive = "c:"
Resume Next
End If
end if    '在这里加个END IF
End Sub
这个里面少了个END IF
#3
VB丶小宇2013-03-22 22:13
回复 2楼 seafish011
非常感谢您的解答,照改后能正常运行,万分感谢。
1