Tag Archives: source code

VB6 : Adding a Grid control to Data Report

A summary in sales/purchase invoice a necessary for clarifying levied tax details or something like that. In VB6 Report allows you use limited controls only (Label, Textbox, Image control etc)

A grid view of summary as follows may add some beauty to your report, isn’t it?


As you know, you can’t  add a grid control to your Visual Basic 6.0 Data Report. So we need to alternate method. I suggest adding a screen picture of the grid instead of the using control, this can be quiet easy. Continue reading

VB6: List all printers using code in Windows

Listing all printers with name, Port in VB6 is simple as listing default printer port using Kernel32 library . Today we going show you how to do this.

As usual we start with function declaration, then define a new function which add all information into a list box. Here we goes

Kernel32 GetProfileString method

Declare Function GetProfileString Lib “kernel32.dll” Alias “GetProfileStringA” (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long

Add printer information into a list box

Public Sub GetPrinterList(lstPrinter As ListBox)Dim PrintData As PrinterDim defprinterpos%

For Each PrintData In Printers

‘ Add printer name and port to list

lstPrinter.AddItem PrintData.DeviceName & ” at: ” & PrintData.Port

‘ Check for default printer

If PrintData.DeviceName = Printer.DeviceName Then defprinterpos = lstPrinter.NewIndex


lstPrinter.ListIndex = defprinterpos%

End Sub

This sub procedure will take list box as argument, and add printer to this list box.

Call the sub

The final line of code just invoke the procedure and see what we have.

Happy coding

Add new fields to Access table using VB6

Let me show how to add a new field into an existing access database using Visual Basic 6.0.Using the tableDef and Filed object you can create new fields. Firstly, you need to create Database and Recordset object, mke sure the DAO access object library. Continue reading

How to auto complete text box in VB6

How to add a auto complete feature in Microsoft Visual Basic 6 ?

With the help of some creepy code, we can save the entry into a data file temporarily and later we can use them as input for auto complete the name/place/text.

The code is work with Text box as well as Combo box. Drop the following code to a module call the methods defined. Continue reading