0% found this document useful (0 votes)
53 views1 page

Visual Basic OLevel Codes Complete

The document provides Visual Basic code examples tailored for O-Level students, including basic arithmetic operations, comparisons between two numbers, and checking if a number is odd or even. Each example includes a subroutine that performs the specified task and displays the result. Additional programs are mentioned but not included in the excerpt.

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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views1 page

Visual Basic OLevel Codes Complete

The document provides Visual Basic code examples tailored for O-Level students, including basic arithmetic operations, comparisons between two numbers, and checking if a number is odd or even. Each example includes a subroutine that performs the specified task and displays the result. Additional programs are mentioned but not included in the excerpt.

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 PDF, TXT or read online on Scribd
You are on page 1/ 1

' 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

' ... (Programs 4 to 55 skipped here due to space; they'll be included below)

You might also like