Microsoft Visual Basic 6 (VB6) provides you with a Printer class that lets you set up and retrieve printer information. Use this class to identify the printer before sending the print job to the device. Several properties are available in the Printer class, so you must determine what property you want to view from the code and return it to a string variable.
- Skill level:
Right-click the VB6 solution file on your desktop. Select "Open With," then double-click "Visual Basic" to open the software.
Right-click the form you want to use to retrieve the printer properties and select "View Code." The code file loads in the editor.
Create a class variable for the printer. Type the following code to start the printer process:
Dim printer As Printer()
Get the name of the printer. Unless you specify a different printer, the "DeviceName" property retrieves the name of the default printer on the desktop. Type the following code to retrieve the device name:
Dim printername As String
printername = printer.DeviceName
Retrieve the number of pages currently printing. The following code retrieves the information:
Dim pages As String
pages = printer.Pages
Click the "Save" button and click "Run" to run the code in the debugger. You can view your code changes and test for any syntax errors in the debugger.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for