开发者

VB6 Form.Show is not working

I 开发者_Go百科have a project with graphs that can be printed. When you click the print button, a Print Preview form loads with:

Public Sub print()
   printPreview.Show
End Sub

Everything works fine on my development machine both when I run it in debug mode and when I install our distributed installation package.

For some reason though, everyone else who tries to print can never get the preview to show up. Further testing shows that Load function of the preview is never called and anything after Show in the print function is ignored. It's as if the function jumps right to End Sub of the print function.

It seems like the printPreview.Show is failing but there is no error, warning or ANY indication of something wrong other than the fact that the form does not appear. Has anyone ever experienced something like this?


You may have an On Error Resume Next up the call stack somewhere.

You may want to change the function to have it's own error handler and trap messages there or do On Error GoTo 0.

I'd also check the event logs on the machines where this is failing for any additional information.


Do you have any "On Error ..." in effect at the time the print methos gets called? I guess that your printPreview form relies on one or more components that isn't installed on the users machines and that an error is thrown, which you catch without realizing it.


Have you tried passing vbModal, just to see what happens? Also (you might already have done this), put a few debug statements into the code:

Public Sub print()
   Debug.Print "Before show"
   printPreview.Show
   Debug.Print "After Show"
End Sub

And put some in Form_Load and Class_Initialize (called implicitly if the form instance doesn’t already exist!) of the print preview form, as well:

' In the print preview form:

Public Sub Class_Initialize()
    Debug.Print "Start of PrintPreview constructor"
    ' … rest of the code.
    Debug.Print "End of PrintPreview constructor"
End Sub

Private Sub Form_Load()
    Debug.Print "Start of PrintPreview.Form_Load"
    ' … rest of the code.
    Debug.Print "End of PrintPreview.Form_Load"
End Sub

And make sure where exactly the output is missing.

From your rather sparse description I suspect that the Class_Initialize method provokes an error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜