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! :)

Saturday, February 12, 2011

Searching a letter within a text

Hi guys! in this program the user will type any text and the user will input on the next textbox the letter that is going to be searched. After that the user will click the button name "Search" then the output will show. Below is the source code of this program. Hope this will help you. Enjoy and Happy coding! :)


Private Sub Command1_Click()
Dim x, y As Integer
    For x = 1 To Len(Text1.Text)
        If Mid(Text1.Text, x, 1) = Text2.Text Then
            y = y + 1
        End If
    Next
Label1.Caption = y
Label2.Caption = Text2.Text & " 's"
End Sub

Multiplication Table

Hi guys! this is simple program on how to generate a multiplication table. below is the source code on how to generate it. Hope this will help you. Enjoy and Happy coding! :)


Private Sub Command1_Click()
Dim a As Integer
Label1.Caption = Empty
For row = 1 To Text1.Text
    For col = 1 To Text1.Text
        a = row * col
        Label1.Caption = Label1.Caption & a & "     "
    Next
    Label1.Caption = Label1.Caption & vbCrLf
Next
End Sub

Monday, February 7, 2011

String Functions w/ size

Hi guys! this is the sample code of the basic string function shown above with size of the strings you want to display.Hope this will help you.
Happy coding! :)


Private Sub Command1_Click()
Label1.Caption = Left(Text1.Text, Text2.Text)
Label2.Caption = Right(Text1.Text, Text2.Text)
Label3.Caption = Mid(Text1.Text, Len(Text1.Text) / 2, Text2.Text)
Label13.Caption = UCase(Text1.Text)
Label12.Caption = LCase(Text1.Text)
End Sub

Simple text encryption

Hi guys! this is the sample code of the encrypted text shown above. Hope this will help you. Enjoy!
Happy coding! :)


Private Sub Command1_Click()
For x = 1 To Len(Text1.Text)
    Label1.Caption = Label1.Caption & Chr(Asc(Mid(Text1.Text, x, 1)) + 5)
Next
End Sub