gui
gui
gui
Program Code:
Write a program using MessageBox and Arithmetic Expressions –
Module Module1
Dim i, j, r As Integer
Sub Main()
Console.WriteLine("Enter First Value=")
i = Console.ReadLine()
Console.WriteLine("Enter Second Value=")
j = Console.ReadLine()
Console.ReadLine()
MsgBox("Addition =" & (i + j))
MsgBox("Substraction =" & (i - j))
MsgBox("Multiplication =" & (i * j))
MsgBox("Division =" & (i / j))
End Sub
End Module
Addition=60
OK
2. Write a program using InputBox(), MessageBox() & perform various Arithmetic
expressions.
End Sub
End Class
Output:
Inputbox_Msgbox
Addition = 68
OK
Practical No: 04
. Program Code:
Write a program using if-else statement –
Module Module1
Sub Main()
Dim n As Integer
Console.WriteLine("Enter a Number")
n = Console.ReadLine()
If (n > 0) Then
Console.WriteLine("Number is Positive")
Else
Console.WriteLine("Number is Negative")
End If
Console.ReadLine()
End Sub
End Module
Module Module1
Sub Main()
Dim a, b, c As Integer
Console.Write("Enter the values of a, b and c:")
a = Val(Console.ReadLine())
b = Val(Console.ReadLine())
c = Val(Console.ReadLine())
If (a > b) Then
If (a > c) Then
Console.WriteLine("Greatest Number is:" & a)
Else
Console.WriteLine("Greatest Number is:" & c)
End If
Else
If (b > c) Then
Module Module1
Dim i As Integer
Sub Main()
Console.WriteLine("Enter Number")
i = Console.ReadLine()
If ((i Mod 2) = 0) Then
Console.WriteLine("Number is Even")
Else
Console.WriteLine("Number is Odd")
End If
Console.ReadLine()
End Sub
End Module
X. Program Code :
Write a Program using select case statement in VB.NET
Module Module1
Sub Main()
Dim grade As String
Console.WriteLine("Enter Your grade")
grade = Console.ReadLine()
Select Case grade
Case "A"
Console.WriteLine("High Distinction")
Case "A-"
Console.WriteLine("Distinction")
Case "B"
Console.WriteLine("Credit")
Case "C"
Console.WriteLine("Pass")
Case Else
Console.WriteLine("Fail")
End Select
Console.ReadLine()
End Sub
End Module
Module Module1
Sub Main()
Dim str As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim numberOfVowels As Integer = 0
Output:
Number of vowels: 5
2. Develop a program for performing arithmetic operations –
Module Module1
Sub Main()
Dim N1, N2, Result, choice As Integer
Do
Console.WriteLine("Menu:-\n1.Add\n2.Subtract" & _
"\n3.Multiply\n4.Divide\n5.Exit.")
Console.WriteLine("Enter choice: ")
choice = Console.ReadLine()
Console.WriteLine("Enter number 1: ")
N1 = Console.ReadLine()
Console.WriteLine("Enter number 2: ")
N2 = Console.ReadLine()
Select Case choice
Case 1
Result = N1 + N2
Console.WriteLine("Sum = " & Result)
Case 2
Result = N1 - N2
Console.WriteLine("Difference = " & Result)
Case 3
Result = N1 * N2
Console.WriteLine("Product = " & Result)
Case 4
Result = N1 \ N2
Console.WriteLine("Quotient = " & Result)
Result = N1 Mod N2
Console.WriteLine("Remainder = " & Result)
Case 5
Exit Sub
Case Else
Console.WriteLine("Wrong option ...")
End Select
Loop While choice <> 5
End Sub
End Module
Output:
Menu:-\n1.Add\n2.Subtract\n3.Multiply\n4.Divide\n5.Exit.
Enter choice: 1
Enter number 1: 57
Enter number 2: 87
Sum = 144
Menu:-\n1.Add\n2.Subtract\n3.Multiply\n4.Divide\n5.Exit.
Enter choice: 5
[Type text]
Practical No 06
Program Code :
Write a program using While & Do loop in VB.Net
For while loop.
Module Module1
Sub Main()
Dim a As Integer = 1
While (a < 10)
Console.WriteLine(a)
a = a + 1
End While
Console.ReadLine()
End Sub
End Module
Output:
1
2
3
4
5
6
7
8
9
For Do loop.
Module Module1
Sub Main()
Dim a As Integer = 1
Do
Console.WriteLine(a)
a = a + 1
Loop While (a<10)
Console.ReadLine()
End Sub
End Module
Output:
1
2
3
4
5
6
7
8
9
[Type text]
[Type text]
1. Write a program using While statement to print the prime numbers between 1 to 100.
Module Module1
Sub Main()
Dim i, j, c As Integer
c=0
i=2
While (i <= 100)
j=2
While (j < i)
If (i Mod j = 0) Then
Exit While
ElseIf (i = j + 1) Then
Console.WriteLine(i)
End If
j=j+1
End While
i=i+1
End While
Console.ReadLine()
End Sub
End Module
OUTPUT:
[Type text]
[Type text]
2. Write a program using While statement to print even-odd numbers between 1 to 50.
Module Module1
Sub Main()
Dim i As Integer = 1
While (i <= 50)
If ((i Mod 2) = 0) Then
Console.WriteLine(i & " Even")
Else
Console.WriteLine(i & " Odd")
End If
i=i+1
End While
Console.ReadLine()
End Sub
End Module
Output:
[Type text]
[Type text]
Practical No 07
Program Code
Module Module1
Sub Main()
Dim Array() As Integer = {12, 34, 56, 37, 78, 53, 98, 22, 19, 68}
Dim Key As Integer
Dim IsKeyFoundFlag As Boolean = False
[Type text]
[Type text]
3. .Write program using For Next loop statement tot find the Armstrong
numbers between 1 to 500. (153 is Armstrong Number – 13 + 53 + 33 = 153)
Module Module1
Sub Main()
Dim i As Integer
If (sum = i) Then
Console.WriteLine(i)
End If
Next
Console.ReadLine()
End Sub
End Module
Output :
1
153
370
371
407
[Type text]
[Type text]
Practical No 08
Program Code :
Write a program to demonstrate the use of Button, Textbox and Label.
For i = 1 To num
fact *= i
Next
Factorial = fact
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fact As Long
fact = Factorial(TextBox1.Text)
MessageBox.Show("Factorial of " & TextBox1.Text &
" is " & fact, "Factorial", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
End Class
[Type text]
[Type text]
1.
[Type text]
[Type text]
2. Write a program to perform the arithmetic operations using controls Label, Button and
TextBox.
Public Class Form1
Dim n As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
n = Val(TextBox1.Text) + Val(TextBox2.Text)
TextBox3.Text = n
End Sub
Output:
[Type text]
[Type text]
3. Write a program to change the background color of the form when user clicks on
different buttons.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.BackColor = Color.Red
End Sub
Output:
[Type text]
[Type text]
Practical No 09
Program Code :
Write a program to demonstrate the use of CheckBox and RadioButton.
Code to check Radio Buttons State
Output :
[Type text]
[Type text]
Code to display message when the checkbox is checked -
OUTPUT :
[Type text]
[Type text]
1. Write the program using RadioButton to change the bulb state ON/OFF.
PictureBox1.Show()
PictureBox2.Hide()
End Sub
End Class
OUTPUT:
[Type text]
[Type text]
1. Write a program to change the ForeColor of the text in Label using different RadioButtons
such Red, Green, Blue.
OUTPUT:
[Type text]
[Type text]
Practical No 10
Program Code
1. Write a program to demonstrate the use of ListBox and ComboBox.
(Code for Add Items to ListBox & Remove Selected Item from ListBox)
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
End Sub
[Type text]
[Type text]
1. Write the program to select multiple subjects using ListBox control.
Output :
[Type text]
[Type text]
2. Write the program to select colleges using single ComboBox.
OUTPUT:
[Type text]
[Type text]
Exercise :
[Type text]
[Type text]
ListBox1.Items.Add("DCC")
ListBox1.Items.Add("GUI")
ListBox1.Items.Add("SEN")
End If
End Sub
End Class
Output :
[Type text]
[Type text]
[Type text]