Gad Practicals
Gad Practicals
1. Implement an application to perform arithmetic operation and display result using message box.
2. Implement an application for finding greatest of two or three numbers.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, c As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
If a > b And a > c Then
MsgBox("Greatest number is " & a)
ElseIf b > c And b > a Then
MsgBox("Greatest number is " & b)
Else
MsgBox("Greatest number is " & c)
End If
End Sub
End Class
3. Implement an application using if else statement to find whether the given number is even or
odd.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (Val(TextBox1.Text) Mod 2 = 0) Then
MsgBox("Number is even")
Else
MsgBox("Number is odd")
End If
End Sub
End Class
4. Implement an application using if else statement to find whether the given number is Positive
or negative.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (Val(TextBox1.Text) >= 0) Then
MsgBox("Number is positive")
Else
MsgBox("Number is negative")
End If
End Sub
End Class
6.. Develop an application to display day name as per selected day no. from 1 to 7 using select case.
Form1
Public Class Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim a As Integer
a = Val(TextBox1.Text)
Select Case a
Case 1
TextBox2.Text = "Monday"
Case 2
TextBox2.Text = "Tuesday"
Case 3
TextBox2.Text = "Wednesday"
Case 4
TextBox2.Text = "Thursday"
Case 5
TextBox2.Text = "Friday"
Case 6
TextBox2.Text = "Saturday"
Case 7
TextBox2.Text = "Sunday"
End Select
End Sub
End Class
Implement an application to display series of _______ numbers or table of ____ using while loop.
Implement an application to display series of _______ numbers or table of ____ using do while.
For n = 1 To 100
For i = 2 To n - 1
If n Mod i = 0 Then
p = 0
Exit For
Else
p = 1
End If
Next
If p = 1 Then
ListBox1.Items.Add(n)
End If
Next
End Sub
End Class
Implement an application to display Armstrong no.s between 1 to 500
End Sub
End Sub
End Class