Aim:
To write a vb.net program to swarp two numbers.
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to Swarp the number
Program
Public Class swarp
Private Sub swap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a, b As Integer
a = 5
b = 10
c = 0
MessageBox.Show("Before swapping a = " & a & " , b = " & b)
c = a
a = b
b = c
MessageBox.Show("After swapping a = " & a & " , b = " & b)
End Sub
Interface
Result
A vb.net program to Swarp the number was well executed and the output was verified.
2st Exercise
Aim:
To write a vb.net program to perform arithmetic operations with two numbers.
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to perform arithmetic operations the number
Program
Public Class arithmetric
Dim a, b, c As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = TextBox1.Text
b = TextBox2.Text
c = 0
c = a + b
MsgBox("sum of two number=" & c)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
c = a - b
MsgBox("Difference of two number=" & c)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
c = a * b
MsgBox("product of two number=" & c)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
c = a / b
MsgBox("Quotient of two number=" & c)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
c = a Mod b
MsgBox("Remainder of two number=" & c)
End Sub
End Class
Interface
Result
A vb.net program to perform arithmetic operations the number was well executed and the output was verified.
3st Exercise
Aim:
To write a vb.net program to check even or odd number.
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to check even or odd number
Program
Public Class even_and_odd
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer
n = TextBox1.Text
If n Mod 2 = 0 Then
MsgBox("it is an even number")
Else
MsgBox("it is an odd number")
End If
End Sub
End Class
Interface
Result
A vb.net program to check even or odd number was well executed and the output was verified.
4st Exercise
Aim:
To write a vb.net program to print the students grades.
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to print the students grade
Program
Public Class Grade
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mark As Integer
mark = TextBox1.Text
If (mark >= 75) And (mark <= 100) Then
MsgBox("A")
ElseIf (mark >= 60) And (mark <= 74) Then
MsgBox("B")
ElseIf (mark >= 40) And (mark <= 59) Then
MsgBox("C")
ElseIf (mark >= 45) And (mark <= 54) Then
MsgBox("D")
Else
MsgBox("FAILED")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
Interface
Result
A vb.net program to print the students grades was well executed and the output was verified.
5st Exercise
Aim:
To write a vb.net program to check vowel.
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to check vowel
Program
Public Class vowel
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim vowel As Char
vowel = TextBox1.Text
Select Case vowel
Case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U"
MsgBox("it's a vowel")
Case Else
MsgBox("it's not a vowel")
End Select
End Sub
End Class
Interface
Result
A vb.net program to check vowel was well executed and the output was verified.
6st Exercise
Aim:
To write a vb.net program to check the perfect numbers.
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to check the perfect number
Program
Public Class perfect
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer, i = 1, sum = 0
n = TextBox1.Text
Do While (i < n)
If (n Mod i) = 0 Then
sum = sum + i
End If
i = i + 1
Loop
If sum = n Then
MsgBox("ITS THE PERFECT NUMBER")
Else
MsgBox("ITS not THE PERFECT NUMBER")
End If
End Sub
End Class
Interface
Result
A vb.net program to check the perfect the number was well executed and the output was verified.
7st Exercise
Aim:
To write a vb.net program to check a prime number.
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to check a prime number
Program
Public Class prime number
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j As Integer
Dim t As Boolean = True
i = TextBox1.Text
For i = 2 To i - 4
If (i Mod j) = 0 Then
t = False
Exit For
End If
Next i
If t Then
MsgBox("it's a prime number")
Else
MsgBox("not a prime number")
End If
End Sub
End Class
Interface
Result
A vb.net program to check a prime the number was well executed and the output was verified.
8st Exercise
Aim:
To write a vb.net program for linear search(to find a specified element in array).
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to linear search
Program
Public Class Form5
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a(10), i, n, m As Integer, c = 0
n = InputBox("Enter The Size Of An Array")
For i = 0 To n - 1
a(i) = InputBox("Enter The Elements")
Next
m = InputBox("Enter The Number To Be Searched")
For i = 0 To n - 1
If (a(i) = m) Then
c = 1
Exit For
End If
Next
If c = 0 Then
MsgBox("The Number Is Not The List")
Else
MsgBox("The Number Is Found")
End If
End Sub
End Class
Interface
Result
A vb.net program for linear search(to find a specified element in array) was well executed and the output was verified.
9st Exercise
Aim:
To write a vb.net program to perform string methods compare, concat, contains, join, remove, substring, to upper, to lower and trim.
Procedure
- Open Visual Studio
- Open Project
- Create an Interface
- Add Label, Textbox, Button
- Write the Vb.Net Code to perform string methods
Program
Public Class search
'declaration part
Dim str1, str2, results As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
str1 = TextBox1.Text
If (String.Compare(str1, str2)) = 0 Then
MsgBox("equal")
Else
MsgBox("not equal")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
str1 = TextBox1.Text
str2 = TextBox2.Text
results = String.Concat(str1, str2)
MsgBox(results)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
str1 = TextBox1.Text
str2 = TextBox2.Text
If str2.Contains(str2) Then
MsgBox("yes it's found")
Else
MsgBox("no it's not found")
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
str1 = TextBox1.Text
results = str1.Remove(17)
MsgBox(results)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
str1 = TextBox1.Text
results = str1.Substring(17)
MsgBox(results)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
str1 = TextBox1.Text
results = str1.ToLower
MsgBox(results)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
str1 = TextBox1.Text
results = str1.ToUpper
MsgBox(results)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
str1 = TextBox1.Text
results = str1.Trim
MsgBox(results)
End Sub
End Class
Interface
Result
A vb.net program to perform string methods was well executed and the output was verified.
10st Exercise
Aim:
To write a vb.net program to factorial of given numbers.
Procedure
- Open Visual Studio
- Open Project
- Create an Interfacea
- Add Label, Textbox, Button
- Write the Vb.Net Code to factorial of given numbers
Program
Public Class factorial
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer
n = Integer.Parse(TextBox1.Text)
Label2.Text = fact(n).ToString()
End Sub
Private Function fact(ByVal n As Integer)
If (n = 0) Then
fact = 1
Else
fact = n * fact(n - 1)
End If
End Function
End Class
Interface
Result
A vb.net program to factorial of given the number was well executed and the output was verified.
Post a Comment