0% found this document useful (0 votes)
11 views23 pages

Chpter 3

The document discusses basic controls in VB.NET programming including properties, methods, and events of controls as well as examples of creating applications using various controls like labels, textboxes, buttons, listboxes, radiobuttons and checkboxes. It provides code examples for performing arithmetic operations using buttons and textboxes, manipulating radiobuttons and checkboxes, changing label text using buttons, using listboxes to display options, and programming checkboxes.

Uploaded by

jermyn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views23 pages

Chpter 3

The document discusses basic controls in VB.NET programming including properties, methods, and events of controls as well as examples of creating applications using various controls like labels, textboxes, buttons, listboxes, radiobuttons and checkboxes. It provides code examples for performing arithmetic operations using buttons and textboxes, manipulating radiobuttons and checkboxes, changing label text using buttons, using listboxes to display options, and programming checkboxes.

Uploaded by

jermyn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

VB.

NET
PROGRAMMING
Basic Controls in
VB.Net
Chapter 3:

Objective

 Enumerate and explain the uses of the different controls in VB.net


 Understand the characteristics and properties of a control
 Differentiate properties, methods and events
 Create vb.net application with controls.
Chapter 3:

What is an object?

 An object is an element you create on a VB.Net form by using a toolbox


control. A VB form is an example of an object
Chapter 3:

VB control consists of 3 important elements

 Properties – which describe the object. (e.g. Fontsize, Width, Height)


 Methods – cause an object to do something and (e.g.
MessageBox.Show) . Show is the method.
 Events – are what happens when an object does something. (e.g. Mouse
over, Click, Double Click)
Chapter 3:


Chapter 3:
Arithmetic Operations
Label1 Label2
TextBox2
TextBox1 TextBox3

Button1 Button2 Button3 Button4


Chapter 3:
Arithmetic Operations
Chapter 3:
Arithmetic Operations
Variable Declaration:
Dim Num1 As Double
Dim Num2 As Double
Dim Ans As Double

For Button Code:


Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Num1 = Val(TextBox1.Text)
Num2 = Val(TextBox2.Text)
Ans = Num1 + Num2
TextBox3.Text = Ans
Label1.Text = "+"
Chapter 3:

Radio Buttons and CheckBoxes Manipulation

GroupBox2
GroupBox1

CheckBox1
RadioButton1
CheckBox2
RadioButton2
CheckBox3
RadioButton3
CheckBox4
RadioButton4
CheckBox5

Label1 TextBox1
Label2
Button1

TextBox2
Chapter 3:
Radio Buttons and CheckBoxes Manipulation
Chapter 3:
Radio Buttons and CheckBoxes Manipulation
For RadioButton Code:
Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles
RadioButton1.CheckedChanged
TextBox1.Text = "BSIT"
End Sub

For CheckBox Code:


“Change also the control event from CheckedChanged to Click”
Private Sub CheckBox1_Click(sender As System.Object, e As System.EventArgs) Handles CheckBox1.Click
If CheckBox1.Checked Then
TextBox2.Text = Val(TextBox2.Text) + 1
Else
TextBox2.Text = Val(TextBox2.Text) - 1
End If

End Sub
Chapter 3:
Changing the Label Using Code
Label1

Label2

Button
Chapter 3:
Changing the Label Using Code
Chapter 3:
Changing the Label Using Code

For Button Code:


Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Label1.Font = New Font("cosmics sans ms", 12, Label1.Font.Style)

End Sub
Chapter 3:
Program Using Listbox

ListBox1

Label1

Button
Chapter 3:
Program Using Listbox
Chapter 3:
Program Using Listbox

For Button Code:


Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Dim Choice As String

Choice = ListBox1.Text
If Choice = "LANCE" Then
Label1.Text = "LANCE MABUHAY!"
ElseIf Choice = "FREDRIN" Then
Label1.Text = "FREDRIN MABUHAY!"
ElseIf Choice = "GUSION" Then
Label1.Text = "GUSION MABUHAY!"
ElseIf Choice = "LAYLA" Then
Label1.Text = "LAYLA MABUHAY!"
Else
Label1.Text = "PLEASE CHOICE FROM LIST BOX!"
End If

End If
End Sub
Chapter 3:
Program for Check Box

Label1

CheckBox
Chapter 3:
Program for Check Box
Chapter 3:
Program for Check Box

For CheckBox Code:


Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles
CheckBox1.CheckedChanged

If CheckBox1.Checked = True Then


Label1.ForeColor = Color.Red
CheckBox2.Checked = False
CheckBox3.Checked = False
End If

End Sub
Chapter 3:
Exercises #1
Chapter 3:
Exercises #1

You might also like