Monday, March 28, 2011

How to add items in ListView

This is the sample program on how to add items in ListView component in visual basic. Below is the basic code of the program above. Hope this will help you. Happy coding! :)



Private Sub Form_Load()
Dim li As ListItem
With ListView1
    .View = lvwReport
    .ColumnHeaders.Add = "Column #1"
    .ColumnHeaders.Add = "Column #2"
    .ColumnHeaders.Add = "Column #3"
    Set li = .ListItems.Add(, , "Yves")
    li.SubItems(1) = "Jeoffrey"
    li.SubItems(2) = "Jauculan"
End With
End Sub

How to add items in ComboBox component

This is a sample program on how to add items in combo box component. Below is the sample code of the program above. Hope this helps you. Happy Coding! :)


Private Sub Form_Load()
With Combo1
    .AddItem "Yves"
    .AddItem "Jeoffrey"
    .AddItem "Jauculan"
    .AddItem "it-code51.blogspot.com"
End With
End Sub

How to load picture using Picture box component

This is a sample program on how to load a picture using PictureBox component. Hope this one helps you.
The following is the sample code of the program above.


Private Sub Command1_Click()
Picture1.Picture = LoadPicture("C:\Documents and Settings\Yves\Desktop\clients_icon.jpg")
End Sub

Note:
    - the texts inside the double quote (" ") is the path of your image that you want to load.


Happy Coding! :)

How to load rich text file in vb 6.0

Hi guys! in this topic I will teach you how to load a rich text file in visual basic 6.0. like the image above. but before anything else you must first create a ".rtf" or ".RTF" file extension in Microsoft Office Word or any spreadsheet that can create those file extension and then save it as "myword.rtf" or "myword.RTF". after that in Visual Basic interface click the component Rich Textbox and drag it to the form. The following is sample code on how to load rich text file. Hope this one helps you. Happy Coding! :)



Private Sub Form_Load()
RichTextBox1.LoadFile ("C:\Documents and Settings\Yves\Desktop\yves.rtf")
End Sub

Note:
    - the text inside the double quote(" ") are the path of your ".rtf" or ".RTF" file.

Saturday, March 26, 2011

MSFLEXGRID(adding items,column header texts and column width)

Hi guys! this is the MSFLEXGRID component, in this topic i will teach you the basic way to add items in the grid, putting texts in the column header and resizing the grid. below is the basic code of the program above. Hope this will help you. Happy Coding! :)



Private Sub Form_Load()
MSFlexGrid1.Rows = 1
MSFlexGrid1.AddItem "Yves" & vbTab & "Jeoffrey" & vbTab & "Jauculan"
With MSFlexGrid1
    .TextMatrix(0, 0) = "Col # 0"
    .ColWidth(0) = 800
    .TextMatrix(0, 1) = "Col # 1"
    .ColWidth(1) = 2000
    .TextMatrix(0, 2) = "Col # 2"
    .ColWidth(2) = 1800
End With
End Sub

Monday, March 14, 2011

Connecting MS Access in VB6.0

Hello guys! in this topic I will show you how to connect MS Access to Visual Basic 6.0.

Dim conn as ADODB.Connection
Dim strcon as String

strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "MyDatabase.mdb"
    conn.ConnectionString = strcon
    conn.Open

Note:
MyDatabase.mdb(your database name)

Hope this will help you. Enjoy!
Happy Coding! :)