否则,如果不在visual basic 6中工作

时间:2016-02-19 14:03:15

标签: vb6

我想在图片框中显示所选图片。以下是代码:

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

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

Private Sub File1_Click()
On Error GoTo lab
lab:
If Err.Number = 481 Then
    MsgBox ("Please select a valid Picture")
Else
    If Err.Number = 68 Then
        MsgBox ("Device not ready")
    End If
End If
Resume Next
Picture1.Picture = LoadPicture(File1.Path + "\" + File1.FileName)
End Sub

案例481完全正常,但第二种情况,错误68根本不起作用。它显示运行时错误68.以下是输出:

enter image description here

请告诉我上述代码中的错误。

1 个答案:

答案 0 :(得分:1)

您是否通常将错误处理程序放在代码之前可能会引发错误?我无法用自己的简单案例复制这个,但这段代码的结构似乎很可疑。您还有<div id="container"> <div id="left"> This div is as big as it's content</div> <div id="right"><input type="text" style="width:100%" /></div> </div> #left { background: #aaa; float: left} #right { background: cyan; overflow: hidden} 没有循环。试试这个:

Resume Next

您可能需要在其他程序中使用其他错误处理程序,例如:

Private Sub File1_Click()
On Error GoTo lab
Picture1.Picture = LoadPicture(File1.Path + "\" + File1.FileName)
Exit Sub

lab:
Select Case Err.Number
    Case 481 Then
        MsgBox ("Please select a valid Picture")
    Case 68 Then
        MsgBox ("Device not ready")
End Select

End Sub