0% found this document useful (0 votes)
61 views5 pages

Lab 6

The document contains code examples for console and form applications in Visual Basic that take user input of numbers, compare the numbers, and output the results of the comparisons. The console applications prompt for user input, perform conditional checks on the numbers, and write the results to the console. The form applications populate text boxes for input, perform the same conditional checks as the console code, and write the results to labels on the form. The code samples demonstrate different ways to compare numbers and return text outputs based on the comparisons.

Uploaded by

api-287153731
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)
61 views5 pages

Lab 6

The document contains code examples for console and form applications in Visual Basic that take user input of numbers, compare the numbers, and output the results of the comparisons. The console applications prompt for user input, perform conditional checks on the numbers, and write the results to the console. The form applications populate text boxes for input, perform the same conditional checks as the console code, and write the results to labels on the form. The code samples demonstrate different ways to compare numbers and return text outputs based on the comparisons.

Uploaded by

api-287153731
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/ 5

LAB6-1

Con
Imports System.Console
Imports System.Math
Module Module1
Sub Main()
Dim A, B As Double
Write("Enter the first number : ")
A = ReadLine()
Write("Enter the second number : ")
B = ReadLine()
If (A > B) Then
WriteLine(">>> First number is larger than the second. ")
End If
If (A < B) Then
WriteLine(">>> Second number is larger than the first. ")
End If
ReadKey()
End Sub
End Module
//////////////////////////////////////////////////////////////////////////////////////
Form
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim A, B As Double
A = TextBox1.Text
B = TextBox2.Text
If (A > B) Then
Label3.Text = "First number is larger than the second."
End If
If (A < B) Then
Label3.Text = "Second number is larger than the first."
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class

LAB6-2
Con
Imports System.Console
Imports System.Math
Module Module1
Sub Main()
Dim A, B, C As Double
Write("Enter the first number : ")
A = ReadLine()
Write("Enter the second number: ")
B = ReadLine()
Write("Enter the third number: ")
C = ReadLine()
If (A > B) And (A > C) Then
WriteLine(">>> The Largest number is {0}. ", A)
ElseIf (B > A) And (B > C) Then
WriteLine(">>> The Largest number is {0}. ", B)
ElseIf (C > A) And (C > B) Then
WriteLine(">>> The Largest number is {0}. ", C)
End If
ReadKey()
End Sub
End Module

///////////////////////////////////////////////////////////////////////////////
Form

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim A, B, C As Double
A = TextBox1.Text
B = TextBox2.Text
C = TextBox3.Text
If (A > B) And (A > C) Then
Label4.Text = ">>> The Largest number is " & A & " . "
ElseIf (B > A) And (B > C) Then
Label4.Text = ">>> The Largest number is " & B & ". "
ElseIf (C > A) And (C > B) Then
Label4.Text = ">>> The Largest number is " & C & ". "
End If
End Sub
End Class

LAB6-3
Con
Imports System.Console
Imports System.Math
Module Module1
Sub Main()
Dim A As Double
Write("Enter score : ")
A = ReadLine()
If (A < 50) Then
WriteLine("You got F. ")
ElseIf (A < 55) Then
WriteLine("You got D. ")
ElseIf (A < 60) Then
WriteLine("You got C. ")
ElseIf (A < 65) Then
WriteLine("You got C+. ")
ElseIf (A < 73) Then
WriteLine("You got B. ")
ElseIf (A < 80) Then
WriteLine("You got B+. ")
ElseIf (A < 90) Then
WriteLine("You got A. ")
Else
WriteLine("You got A+. ")
End If
ReadKey()
End Sub
End Module

/////////////////////////////////////////////////////////////////////////////////////////////////////////
Form
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim A As Double
A = TextBox1.Text
If (A < 50) Then
Label2.Text = "You got F. "
ElseIf (A < 55) Then
Label2.Text = "You got D. "
ElseIf (A < 60) Then
Label2.Text = "You got C. "
ElseIf (A < 65) Then
Label2.Text = "You got C+. "
ElseIf (A < 73) Then
Label2.Text = "You got B. "
ElseIf (A < 80) Then
Label2.Text = "You got B+. "
ElseIf (A < 90) Then
Label2.Text = "You got A. "
Else
Label2.Text = "You got A+. "
End If

End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class

----------------------------------------------------------------------------------------------------------------------------------------

LAB 6-4
Con
Imports System.Console
Imports System.Math
Module Module1
Sub Main()
Dim A As Double
Write("Enter score :
A = ReadLine()
Select Case A
Case 0 To 49
WriteLine("You
Case 50 To 54
WriteLine("You
Case 55 To 59
WriteLine("You
Case 60 To 64
WriteLine("You
Case 65 To 72
WriteLine("You
Case 73 To 79
WriteLine("You
Case 80 To 89
WriteLine("You
Case 90 To 100
WriteLine("You
End Select
ReadKey()
End Sub
End Module

")

got F. ")
got D. ")
got C. ")
got C+. ")
got B. ")
got B+. ")
got A. ")
got A+. ")

///////////////////////////////////////////////////////////////////////////////////////////////////////////
Form
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim A As Double
A = TextBox1.Text
Select Case A
Case 0 To 49
Label2.Text = "You got F. "
Case 50 To 54

Label2.Text =
Case 55 To 59
Label2.Text =
Case 60 To 64
Label2.Text =
Case 65 To 72
Label2.Text =
Case 73 To 79
Label2.Text =
Case 80 To 89
Label2.Text =
Case 90 To 100
Label2.Text =
End Select
End Sub
End Class

"You got D. "


"You got C. "
"You got C+. "
"You got B. "
"You got B+. "
"You got A. "
"You got A+. "

You might also like