KEMBAR78
Visual Basic 55 Programs Full | PDF
0% found this document useful (0 votes)
34 views2 pages

Visual Basic 55 Programs Full

The document provides Visual Basic code examples for O-Level students, covering basic arithmetic operations, comparison of two numbers, checking if a number is odd or even, a simple login system, calculating the area of a circle, and converting temperature from Celsius to Fahrenheit. Each example includes a brief description and the corresponding code implementation. These examples serve as practical exercises for students to learn programming concepts in Visual Basic.

Uploaded by

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

Visual Basic 55 Programs Full

The document provides Visual Basic code examples for O-Level students, covering basic arithmetic operations, comparison of two numbers, checking if a number is odd or even, a simple login system, calculating the area of a circle, and converting temperature from Celsius to Fahrenheit. Each example includes a brief description and the corresponding code implementation. These examples serve as practical exercises for students to learn programming concepts in Visual Basic.

Uploaded by

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

Visual Basic Code Examples for O-Level

Students
1. Basic Arithmetic Operations

Private Sub cmdCalculate_Click()


Dim num1 As Double
Dim num2 As Double
num1 = Val(txtNum1.Text)
num2 = Val(txtNum2.Text)
lblAdd.Caption = "Sum: " & (num1 + num2)
lblSub.Caption = "Difference: " & (num1 - num2)
lblMul.Caption = "Product: " & (num1 * num2)
lblDiv.Caption = "Quotient: " & (num1 / num2)
End Sub

2. Find the Largest of Two Numbers

Private Sub cmdCompare_Click()


Dim a As Integer
Dim b As Integer
a = Val(txtA.Text)
b = Val(txtB.Text)
If a > b Then
lblResult.Caption = "A is greater"
ElseIf b > a Then
lblResult.Caption = "B is greater"
Else
lblResult.Caption = "Both are equal"
End If
End Sub

3. Odd or Even Checker

Private Sub cmdCheck_Click()


Dim num As Integer
num = Val(txtNumber.Text)
If num Mod 2 = 0 Then
lblResult.Caption = "Even Number"
Else
lblResult.Caption = "Odd Number"
End If
End Sub

4. Simple Login System

Private Sub cmdLogin_Click()


Dim username As String
Dim password As String
username = txtUsername.Text
password = txtPassword.Text
If username = "admin" And password = "1234" Then
MsgBox "Login Successful"
Else
MsgBox "Invalid credentials"
End If
End Sub

5. Area of a Circle

Private Sub cmdArea_Click()


Dim radius As Double
Dim area As Double
radius = Val(txtRadius.Text)
area = 3.1416 * radius * radius
lblArea.Caption = "Area: " & area
End Sub

6. Temperature Converter (Celsius to Fahrenheit)

Private Sub cmdConvert_Click()


Dim celsius As Double
Dim fahrenheit As Double
celsius = Val(txtCelsius.Text)
fahrenheit = (celsius * 9 / 5) + 32
lblFahrenheit.Caption = "Fahrenheit: " & fahrenheit
End Sub

You might also like