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
Monday, March 28, 2011
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
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! :)
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.
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
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! :)
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
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
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
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
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
Sunday, February 6, 2011
Making right angle triangle using asterisk w/ size
Hi guys! this is my right triangle with size 8. Here is the sample code of the image above. Hope this will help you.
Enjoy! and Happy coding!! :)
Private Sub Command1_Click()
For x = 1 To txtsize
For y = 1 To x
Label3.Caption = Label3.Caption & "*"
Next
Label3.Caption = Label3.Caption & vbCrLf
Next
End Sub
Enjoy! and Happy coding!! :)
Private Sub Command1_Click()
For x = 1 To txtsize
For y = 1 To x
Label3.Caption = Label3.Caption & "*"
Next
Label3.Caption = Label3.Caption & vbCrLf
Next
End Sub
Moving your form upside down
Hi guys! this is the sample code of moving your form upside down. Hope this will help you. Enjoy!
Happy coding! :)
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer2.Enabled = True
End Sub
Private Sub Command3_Click()
Timer3.Enabled = True
End Sub
Private Sub Command4_Click()
Timer4.Enabled = True
End Sub
Private Sub Command5_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Interval = 10
Timer2.Interval = 10
Timer3.Interval = 10
Timer4.Interval = 10
End Sub
Private Sub Timer1_Timer()
Me.Top = Me.Top - 10
End Sub
Private Sub Timer2_Timer()
Me.Top = Me.Top + 10
End Sub
Private Sub Timer3_Timer()
Me.Left = Me.Left + 10
End Sub
Private Sub Timer4_Timer()
Me.Left = Me.Left - 10
End Sub
Happy coding! :)
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer2.Enabled = True
End Sub
Private Sub Command3_Click()
Timer3.Enabled = True
End Sub
Private Sub Command4_Click()
Timer4.Enabled = True
End Sub
Private Sub Command5_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Interval = 10
Timer2.Interval = 10
Timer3.Interval = 10
Timer4.Interval = 10
End Sub
Private Sub Timer1_Timer()
Me.Top = Me.Top - 10
End Sub
Private Sub Timer2_Timer()
Me.Top = Me.Top + 10
End Sub
Private Sub Timer3_Timer()
Me.Left = Me.Left + 10
End Sub
Private Sub Timer4_Timer()
Me.Left = Me.Left - 10
End Sub
Stopwatch
Hi guys! this is the sample code of the stopwatch that I made. Hope this will help you. Enjoy and Happy Coding! :)
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_Click()
sec.Caption = "00"
min.Caption = "00"
hour.Caption = "00"
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim h, m, s As Integer
sec.Caption = Val(sec.Caption) + 1
If Val(sec.Caption) < 10 Then
sec.Caption = "0" & sec.Caption
End If
If Val(sec.Caption) = 60 Then
min.Caption = Val(min.Caption) + 1
sec.Caption = "00"
If Val(min.Caption) < 10 Then
min.Caption = "0" & min.Caption
End If
End If
If Val(min.Caption) = 60 Then
hour.Caption = Val(hour.Caption) + 1
min.Caption = "00"
If Val(hour.Caption) < 10 Then
hour.Caption = "0" & hour.Caption
End If
End If
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_Click()
sec.Caption = "00"
min.Caption = "00"
hour.Caption = "00"
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim h, m, s As Integer
sec.Caption = Val(sec.Caption) + 1
If Val(sec.Caption) < 10 Then
sec.Caption = "0" & sec.Caption
End If
If Val(sec.Caption) = 60 Then
min.Caption = Val(min.Caption) + 1
sec.Caption = "00"
If Val(min.Caption) < 10 Then
min.Caption = "0" & min.Caption
End If
End If
If Val(min.Caption) = 60 Then
hour.Caption = Val(hour.Caption) + 1
min.Caption = "00"
If Val(hour.Caption) < 10 Then
hour.Caption = "0" & hour.Caption
End If
End If
End Sub
Moving texts using timer component
Hi guys! this is the sample code of the moving text using the timer component. hope this will help..
Happy coding! :)
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Label1.Left = 0
Label1.Top = 0
Timer1.Interval = 10
End Sub
Private Sub Timer1_Timer()
If Label1.Top = 0 Then
Label1.Left = Label1.Left + 10
End If
If Label1.Left = 5000 Then
Label1.Top = Label1.Top + 10
End If
If Label1.Top = 5000 Then
Label1.Left = Label1.Left - 10
End If
If Label1.Left = 0 Then
Label1.Top = Label1.Top - 10
End If
End Sub
Happy coding! :)
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Label1.Left = 0
Label1.Top = 0
Timer1.Interval = 10
End Sub
Private Sub Timer1_Timer()
If Label1.Top = 0 Then
Label1.Left = Label1.Left + 10
End If
If Label1.Left = 5000 Then
Label1.Top = Label1.Top + 10
End If
If Label1.Top = 5000 Then
Label1.Left = Label1.Left - 10
End If
If Label1.Left = 0 Then
Label1.Top = Label1.Top - 10
End If
End Sub
Friday, February 4, 2011
How to generate 7 random letters
Hi everyone! this is a sample code on how to generate 7 random letters in one click.. hope this will help you!
happy coding!! :)
Private Sub Command1_Click()
Dim x, z As String
Label1.Caption = Empty
For y = 1 To 7
Randomize
x = Round(97 + 25 * Rnd())
z = UCase(Chr(x))
Label1.Caption = Label1.Caption + z
Next
End Sub
happy coding!! :)
Private Sub Command1_Click()
Dim x, z As String
Label1.Caption = Empty
For y = 1 To 7
Randomize
x = Round(97 + 25 * Rnd())
z = UCase(Chr(x))
Label1.Caption = Label1.Caption + z
Next
End Sub
Subscribe to:
Posts (Atom)