vb6 runtime error 482

howtodo

New member
vb6 runtime error 482

שגיאה זו מתקבלת בפקודה Printer.Print או איזשהי פקודת Print אחרת. האם ידוע למשהו מה גורם לבעיה וכיצד פותרים אותה? תודה !!!
 

מס1

New member
תעיין כאן

FIX: Error 486 or 482 Occurs When Using PrintForm -------------------------------------------------------------------------------- The information in this article applies to: Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0 -------------------------------------------------------------------------------- SYMPTOMS Using code that calls the PrintForm method can cause one or more of the following errors after you change a page level setting (for example, Orientation) or you try to print text to the same page: Run-time error '482': Printer Error Run-time error '486': Can't print form image to this type of printer Printer Error Running under Microsoft Windows NT or Windows 2000, the initial call to PrintForm after changing settings works but subsequent attempts fail. Running under Windows 95 or Windows 98, code that makes even a single call to the PrintForm method after changing Orientation or any other page level setting fails with one or more of the preceding errors. RESOLUTION You can circumvent this problem by not using PrintForm and instead employing WIN32 API code. See the References section below for descriptions of these methods. Running under Windows NT or Windows 2000 Calling the EndDoc method after the call to PrintForm fixes the problem. Running under Windows 95 or Windows 98 Calling the EndDoc method before the call to PrintForm skirts the problem but any settings made to the Printer object are lost. This means that PrintForm uses the settings of the current default printer. This was the behavior prior to Visual Basic 6.0. Use the Common Dialog control to change page properties instead of direct assignments to the properties of the Printer object. STATUS Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual Studio 6.0 Service Pack 4. For additional information about Visual Studio service packs, click the article numbers below to view the articles in the Microsoft Knowledge Base: Q258648 INFO: Visual Studio 6.0 Service Pack 4, What, Where, Why Q258649 HOWTO: Tell That Visual Studio 6.0 Service Pack 4 Is Installed You can download Visual Studio Service Pack 4 from the following Microsoft Web site: Visual Studio Product Updates MORE INFORMATION Prior to Visual Basic 6.0, the PrintForm method was completely self contained and ignored any settings made to the Printer object. This was because the Printer object and the PrintForm method each used its own Device Context (DC) for the current printer. Each had its own printer settings that did not affect any other DC. This also meant that PrintForm would end the current print job, start its own job, and end it when finished. In order to give developers the ability to control printer settings for PrintForm and to allow the printing of text on the same pages with the form image, PrintForm was changed to use the DC of the Printer object. Thus, now you can change printer settings and your call to PrintForm uses them. However, when attempting this under Windows 95 or Windows 98, or when this is done multiple times within a print job under Windows NT or Windows 2000, the errors listed in the Symptoms section can occur. You can get around this problem by replacing PrintForm with WIN32 API code (see References below) or by using the EndDoc method, which ends the print job and allows a new job to start. Also, under Windows 95 and Windows 98, you can use the printer Common Dialog instead of direct assignments to Printer.Orientation. While using EndDoc allows you to print text in the same code that uses PrintForm, you still cannot put the form image and text on the same page. However, you can print text and your form image on the same page using API calls. Steps to Reproduce Behavior Create a new Standard EXE project. Form1 is created by default. Add the following to the module of Form1: Private Sub Form_Click() Printer.Orientation = vbPRORPortrait PrintForm Printer.Orientation = vbPRORLandscape PrintForm End Sub Run the project and click on the form. The error(s) occur. If you are running under Windows 95 or Windows 98, this occurs on the first PrintForm call. The errors occur on the second call when you are running Windows NT or Windows 2000. WorkArounds Windows NT and Windows 2000 Continue with the project created in the preceding steps and add calls to the EndDoc method after each call to PrintForm, so that your code appears as follows: Private Sub Form_Click() Printer.Orientation = vbPRORPortrait PrintForm Printer.EndDoc Printer.Orientation = vbPRORLandscape PrintForm End Sub Run the project and click on the form. Your form should print on two pages, once in portrait and once in landscape. Windows 95 and Windows 98 Continue with the original project created previously and add calls to the EndDoc method before each call to PrintForm, so that your code appears as follows: Private Sub Form_Click() Printer.Orientation = vbPRORPortrait Printer.EndDoc PrintForm Printer.Orientation = vbPRORLandscape Printer.EndDoc PrintForm End Sub Run the project and click on the form. Your form should print on two pages, but each time it just uses the default orientation for the current printer. -or- Continue with the original project created above and add calls to the Common Dialog control to change page settings instead of using direct assignments, so that your code appears as follows: Private Sub Form_Click() CommonDialog1.ShowPrinter ' set to Landscape PrintForm CommonDialog1.ShowPrinter ' set to Portrait PrintForm End Sub From the Project menu, choose Components and then select Microsoft Common Dialog Control 6.0. Click OK. Add a CommonDialog control to Form1. Run the project and click on the form. You are prompted twice with a printer dialog. Select a different orientation each time. Your form should print on two pages, once in landscape and once in portrait​
 
למעלה