2.1 Using Text
Box-A multiplication program
In this program, you
insert two textboxes , three labels and one button. The two textboxes are for
the users to enter two numbers, one label is to display the multiplication
operator and the other label is to display the equal sign. The last label is to
display the answer.
|
2.2 Using
the ListBox-A program to add items to a list box
This program will
add one item at a time as the user enter an item into the TextBox and click the
Add button.
|
The code
Class Frm1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim item As String
item = TextBox1.Text
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim item As String
item = TextBox1.Text
'To add items to a listbox
ListBox1.Items.Add(item)
End Sub
End Class
ListBox1.Items.Add(item)
End Sub
End Class
2.3 Using the PictureBox
In this program, we
insert a PictureBox and a Button into the form. Make sure to set the SizeMode
property of the PictureBox to StretchImage so that the whole picture can be
viewed in the picture box. Key in the code as shown below and you can load an image
from a certain image file into the PictureBox.
|
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'To load an image into the PictureBox from an image file
PictureBox1.Image = Image.FromFile("c:\Users\Public\Pictures\Sample Pictures\Frangipani Flowers.jpg")
End Sub
Tidak ada komentar:
Posting Komentar