

































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


































































A list of common controls
Difference between Textbox and Label
Calculating using Textbox
Define Lists and Combo box
Adding Items in the list box or combo box
Using the Text Box and Label
from the user.
guides to the users , it can also be used to display
outputs.
numeric data by using the function Val(text).
Using List box and Combo Box
where the user can click and select the items
from the list.
present a list of items where the user can click
and select the items from the list.
Defining datatypes
Declaring a Variable
Defining arithmetic operators
Calculations using variables
Data type - Specifies type of data variable can store
Performing Calculations with Variables
Arithmetic Operators
^ Exponential e.g. 3^2=3*3=
/ Floating Point Division e.g. 5/2=2.
\ Integer Division e.g. 5\2=
MOD Modulus (remainder from division) e.g. 7 mod 2=
& String Concatenation (putting them together)
e.g. “united” & “states”=united states
Handles Button1.Click
Math.Sqrt(X)
Square root
Sqrt(4)=
Math.Int(X)
Int(2.1234)=
Math.Round(X)
To the nearest
integer
Round(2.45)=
Math.Abs(X)
Abs(-34)=
Math.Log(X)
Program: calculate the roots
of a quadratic equation given
a, b and c
Private Sub
Quadraticbutton_Click()
Dim A As Integer,=0 B As Integer=
Dim C As Integer=
Dim R1 As Double =0.0, R2 As Double=0.
A = txtA.Text
B = txtB.Text
C = txtC.Text
R1 = (-B+Sqr(B^2-4.0AC))/(2.0*A)
R2 = (-B-Sqr(B^2-4.0AC))/(2.0*A)
outResults.AppendText(“Roots are:”&R1&R2)
End Sub
COM223 13
Example
EventArgs) Handles Button1.Click
The InputBox( ) Function and The
MsgBox( ) Function
value or a message in the form of text.
position)
WEEK 4: The Selection Process in Visual Basic
Describe the various types of decisions that can be
made in a computer program.
Understand the various comparison operators used
in implementing decisions in Visual Basic.
Use the If-Then-Else, If-Then-Else If, and Case
decision structures.
A program for grading students marks using if
statement
Dim myNumber As Integer
myNumber = TextBox1.Text
If myNumber > 100 Then
Label2.Text = ” Congratulation! You win a lucky prize”
Else Label2.Text = ” Sorry, You did not win any prize”
End If
IF-THEN-ELSEIF DECISION
STRUCTURE
One way to implement a multiple alternative decision
structure is through the If-Then-ElseIf decision structure:
(eliminates need for multiple End If statements)
If condition1 True Then
first set of statements
ElseIf c ondition2 True Then
second set of statements
ElseIf condition3 True Then
third set of statements
Else
last set of statements
End if