Adding a property to a user control in VB6 requires 4 subroutines to be filled, the Let/Set, Get and property Bags respectively.
Let and get have the variant as return type as an argument, which means any value can be accessed through the property.
Public Property Get Interval() As Variant
Interval = Timer1.Interval
Public Property Let Interval(ByVal vNewValue As Variant)
Timer1.Interval = vNewValue
Suppose you want to change how do you get the Font Dialog within the Property Window. This can be possible with use of stdfont in place of Variant as follows
Public Property Set Font(ByVal Nfont As StdFont)
Set lbl_Time.Font = Nfont
Public Property Get Font() As StdFont
Set Font = UserControl.lbl_Time.Font
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%
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.
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 Add new fields to Access table using 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 How to auto complete text box in VB6
Here is how you can input and retrieve data into and from Microsoft Flex gridcontol in Visual Basic 6, just drag and drop and text box and flex grid. and do these code Continue reading Access and input data from MSFlexgrid control in VB6
How to delete selected items from a data table (Access) in Visual basic 6.0 ? Users can select the item using a list view control.
Get the count of selected items first Continue reading Delete selected (treeview) rows from data table in Visual basic 6.0