0% found this document useful (0 votes)
34 views

Gad Practicals

The document describes various programs implemented in Visual Basic to perform operations like checking vowels and consonants, finding greatest of numbers, checking even-odd, positive-negative, displaying day name, series, tables using loops, finding factorial, Fibonacci series, prime numbers, Armstrong numbers and reversing a number.

Uploaded by

shantanukapse76
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)
34 views

Gad Practicals

The document describes various programs implemented in Visual Basic to perform operations like checking vowels and consonants, finding greatest of numbers, checking even-odd, positive-negative, displaying day name, series, tables using loops, finding factorial, Fibonacci series, prime numbers, Armstrong numbers and reversing a number.

Uploaded by

shantanukapse76
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/ 8

5. Implement an application to input an alphabet and check whether it is Vowel and Consonant.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ch As Char
ch = TextBox1.Text
Select Case ch
Case "A", "E", "I", "O", "U"
MessageBox.Show(ch + " is Vowel")
Case "a", "e", "i", "o", "u"
MessageBox.Show(ch + " is Vowel")
Case Else
MessageBox.Show(ch + " is Consonant")
End Select
End Sub
End Class

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.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Num, a, ans As Integer
Num = 1
a = Val(TextBox1.Text)
While (Num <= 10)
ans = Num * a
ListBox1.Items.Add(ans)
Num = Num + 1
End While
End Sub
End Class

Implement an application to display series of _______ numbers or table of ____ using do while.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Num, a, ans As Integer
Num = 1
a = Val(TextBox1.Text)
Do
ans = Num * a
ListBox1.Items.Add(ans)
Num = Num + 1
Loop While (Num <= 10)
End Sub
End Class
Implement an application to display series of _______ numbers or table of ____ using for loop.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Num, a, ans As Integer
a = Val(TextBox1.Text)
For Num = 1 To 10
ans = Num * a
ListBox1.Items.Add(ans)
Next
End Sub
End Class
Implement an application to check no. of vowels and consonants in string using For-Each loop.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim countv As Integer = 0
Dim countconsonant As Integer = 0
Dim input As String
input = TextBox1.Text
For Each ch In input
If "aeiouAEIOU".Contains(ch) Then
countv += 1
ElseIf Char.IsLetter(ch) Then
countconsonant += 1
End If
TextBox2.Text = countv
TextBox3.Text = countconsonant
Next
End Sub
End Class

Implement an application to find factorial of a given no.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim n, f, i As Integer
f = 1
n = Val(TextBox1.Text)
For i = 1 To n
f = f * i
Next
MsgBox("Factorial is: " & f)
End Sub
End Class
Implement an application to display Fibonacci series up to given no.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, n, i, s As Integer
n = Val(TextBox1.Text)
a = 0
b = 1
ListBox1.Items.Add(a)
ListBox1.Items.Add(b)
For i = 1 To n - 2
s = a + b
ListBox1.Items.Add(s)
a = b
b = s
Next
End Sub
End Class

Implement an application to display prime no.s between 1 to 100.


Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim p, n, i As Integer
p = 1

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

Public Class Form1

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


Dim i As Integer
For i = 1 To 500
Dim sum, num, digit As Integer
sum = 0
num = i
While (num > 0)
digit = num Mod 10
sum += (digit * digit * digit)
num = num \ 10
End While
If (sum = i) Then
ListBox1.Items.Add(i)
End If
Next
End Sub
End Class
Develop an application using Text box, label and button to display reverse of no.

Public Class Form1

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

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Dim rev As Integer
Dim digit, num, org As Integer
num = Val(TextBox1.Text)
org = num
While num > 0
digit = num Mod 10
rev = rev * 10 + digit
num = num / 10
End While
MsgBox("Reverse of number is " & rev)

End Sub
End Class

You might also like