1.
Implement a program to generate the result of arithmetic expression(windows applications)
Public Class Form1
Dim a As Integer
Dim b As Integer
Dim c As Integer
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
a = Val(TextBox1.Text)
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
b = Val(TextBox1.Text)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
c=a+b
MsgBox("Addition is " & c)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
c=a-b
MsgBox("Subtracton is " & c)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
c=a*b
MsgBox("Multiplication is " & c)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
c=a/b
MsgBox("Division is " & c)
End Sub
End Class
Output
2. Write a program using inputbox(),msgbox() and display the result of arithmatic operation
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim i As Integer
Dim j As Integer
Dim r As Integer
i = InputBox("Enter first number")
j = InputBox("Enter second number")
r = Val(i) + Val(j)
MsgBox("Addition is =" & r)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim i As Integer
Dim j As Integer
Dim r As Integer
i = InputBox("Enter first number")
j = InputBox("Enter second number")
r = Val(i) - Val(j)
MsgBox("Subtraction is =" & r)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim i As Integer
Dim j As Integer
Dim r As Integer
i = InputBox("Enter first number")
j = InputBox("Enter second number")
r = Val(i) * Val(j)
MsgBox("Multiplication is =" & r)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim i As Integer
Dim j As Integer
Dim r As Integer
i = InputBox("Enter first number")
j = InputBox("Enter second number")
r = Val(i) / Val(j)
MsgBox("Division is =" & r)
End Sub
End Class
3. Write a program using while to print prime number between 1 to 100 using flag
Imports System
Imports System.Diagnostics.Metrics
Imports System.Runtime.Serialization
Imports System.Security.Authentication.ExtendedProtection
Imports System.Threading
Module Program
Sub main()
Dim flag As Boolean
Dim i, count As Integer
i=2
count = 0
For i = 2 To 100
flag = False
For j = 2 To i - 1
If ((i Mod j) = 0) Then
flag = True
Exit For
Else
flag = False
End If
Next
If (flag = False) Then
count += 1
Console.WriteLine(i)
End If
Next
Console.WriteLine("The Count IS " & count)
Console.ReadLine()
End Sub
End Module
Output
4. implement a program to find greatest of three numbers
Imports System
Module Program
Sub Main(args As String())
Dim a, b, c As Integer
Console.WriteLine("Enter value of a: ")
a = Console.ReadLine()
Console.WriteLine("Enter value of b: ")
b = Console.ReadLine()
Console.WriteLine("Enter value of c: ")
c = Console.ReadLine()
If (a > b) Then
If (a > c) Then
Console.WriteLine("Greater number a ")
Else
Console.WriteLine("Greater number c ")
End If
Else
If (b > c) Then
Console.WriteLine("Greater number b ")
Else
Console.WriteLine("Greater number c ")
End If
End If
Console.ReadLine()
End Sub
End Module
Output
5. Develop a program for performing arithmetic operation using select case
Imports System
Module Program
Sub Main(args As String())
Dim a, b, ch, c As Integer
Console.WriteLine("Enter value of a: ")
a = Console.ReadLine()
Console.WriteLine("Enter value of b: ")
b = Console.ReadLine()
Console.WriteLine("1.Addition ")
Console.WriteLine("2.Subtraction ")
Console.WriteLine("3.Multiplication ")
Console.WriteLine("4.Division ")
Console.WriteLine("Enter what you want to perform ")
ch = Console.ReadLine()
Select Case ch
Case 1
c=a+b
Console.WriteLine("Addition is " & c)
Case 2
c=a-b
Console.WriteLine("Subtraction is " & c)
Case 3
c=a*b
Console.WriteLine("Multiplition is " & c)
Case 4
c=a/b
Console.WriteLine("Division is " & c)
Case Else
Console.WriteLine("Wrong input")
End Select
End Sub
End Module
Output
6. write a program using SELECT CASE STATEMENT to count the vowel from A to Z alphabets
(Windows application )
Public Class Form1
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim c, i As Integer
Dim st As String
st = (TextBox1.Text)
c=0
For i = 0 To TextBox1.Text.Length - 1
Select Case TextBox1.Text.ToCharArray(i, 1)
Case "a", "e", "i", "o", "u"
c += 1
Case "A", "E", "I", "O", "U"
c += 1
End Select
Next
MsgBox("The Vowel count in your String is " & c)
End Sub
End Class
Output
7. Write a program using while statement to print 1 to 100 EVEN ODD number (Windows
Application)
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim i As Integer = 0
While (i <= 100)
If ((i Mod 2) = 0) Then
TextBox1.Text = TextBox1.Text & " " & i
Else
TextBox2.Text = TextBox2.Text & " " & i
End If
i=i+1
End While
End Sub
End Class
Output
8. Write a program to display armstrong numbers from 1 to 2000
10.Write a program to generate a button at runtime
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim b As New Button
b.Location = New Point(100, 100)
b.Size = New Point(100, 100)
b.Text = "shruti"
b.BackColor = Color.Red
b.TextAlign = ContentAlignment.BottomRight
Me.Controls.Add(b)
End Sub
End Class
Output
11. Write a program to select multiple subjects using listbox control
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ListBox1.Items.Remove(TextBox1.Text)
End Sub
End Class
Output
12. Write a program to generate panel control at run time(Windows application)
Public Class Form1
Private Sub Form1_Load_1(sender As Object, e As EventArgs) Handles MyBase.Load
Dim p As New Panel
p.Location = New Point(100, 100)
p.Size = New Point(400, 200)
p.BackColor = Color.Pink
Dim t As New TextBox
t.Size = New Point(400, 200)
t.Text = "Enter your name "
p.Controls.Add(t)
Dim r As New RadioButton
r.Size = New Point(200, 200)
p.Controls.Add(r)
Dim c As New CheckBox
c.Location = New Point(10, 50)
c.Text = "ss"
c.Size = New Point(400, 200)
p.Controls.Add(c)
Controls.Add(p)
End Sub
End Class
13. write a program to on and off the bulb using radiobutton (windows )
Public Class Form1
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton1.CheckedChanged
PictureBox1.Show()
PictureBox2.Hide()
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton2.CheckedChanged
PictureBox2.Show()
PictureBox1.Hide()
End Sub
End Class
14 Write a program using erroprovider control to validiate username and password
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = " " Then
ErrorProvider1.SetError(TextBox1, "Please Enter your name")
Else
ErrorProvider1.SetError(TextBox2, "Please Enter your password")
End If
ErrorProvider1.SetError(TextBox2, " Please Enter valid password")
ErrorProvider1.SetError(TextBox1, "Please Enter your name")
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
Output
15.Implement a program to find the factorial of a number using recursion (simply use parameterised
function)(windows application)
Public Class Form1
Function fact(ByVal f As Integer)
If f >= 1 Then
Return f * fact(f - 1)
Else
Return 1
End If
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
label2.text = fact(TextBox1.Text)
End Sub
End Class
16. write a program to identify the volume of box with three data members length,breadth,height
Imports System
Module Program
Public Class Volume_of_box
Dim l, b, h As Double
Sub acceptdata(ByVal _l As Double, ByVal _b As Double, ByVal _h As Double)
l = _l
b = _b
h = _h
End Sub
Sub calculate()
Dim v As Double
v=l*b*h
Console.WriteLine("The volume of box with lenght ={0} & breadth={1} & height={2} is {3} ", {l,
b, h, v})
Console.WriteLine(v)
End Sub
End Class
Sub main()
Dim v As New Volume_of_box()
Dim a, b, c As Double
Console.WriteLine("Enter lenghth,breadth and height :-- ")
a = Console.ReadLine()
b = Console.ReadLine()
c = Console.ReadLine()
v.acceptdata(a, b, c)
v.calculate()
Console.ReadKey()
End Sub
End Module
Output
17. Implement a program to find area of circle using parameterized constructor
Imports System
Module Program
Public Class Circle
Dim rad As Double
Public Sub New(ByVal _r As Double)
rad = _r
End Sub
Sub calculate()
Dim area As Double
area = 3.14 * rad * rad
Console.WriteLine("The radius of circle rad ={0} & and Area is {1} ", {rad, area})
Console.WriteLine(area)
End Sub
End Class
Sub main()
Dim radius As Double
Console.WriteLine("Enter radius of Circle :-- ")
radius = Console.ReadLine()
Dim v As New Circle(radius)
v.calculate()
Console.ReadKey()
End Sub
End Module
Output
18. Write any program of exception handling of your choice
Public Class Form1
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, div As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
Try
div = a / b
Label4.Text = "Division is" & div
Catch ex As Exception
Label4.Text = "Exception Division by number zero"
End Try
End Sub
End Class
Output
19. Write a program to display the TRAFFIC SIGNAL using timer control
Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If PictureBox1.Visible Then
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = True
ElseIf PictureBox3.Visible Then
PictureBox1.Visible = False
PictureBox2.Visible = True
PictureBox3.Visible = False
Else
PictureBox1.Visible = True
PictureBox2.Visible = False
PictureBox3.Visible = False
End If
End Sub
Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
Output
20. Implement a program using the combobox and listbox by selecting semester and display subjects
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("1")
ComboBox1.Items.Add("2")
ComboBox1.Items.Add("3")
ComboBox1.Items.Add("4")
ComboBox1.Items.Add("5")
End Sub
Private Sub Combox1SelectedIndexChanged(sender As Object, e As EventArgs) Handles
ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedIndex = 0 Then
ListBox1.Items.Clear()
ListBox1.Items.Add("English")
ListBox1.Items.Add("BMS")
ListBox1.Items.Add("Chemistry")
End If
If ComboBox1.SelectedIndex = 1 Then
ListBox1.Items.Clear()
ListBox1.Items.Add("M2")
ListBox1.Items.Add("C programming")
ListBox1.Items.Add("EEC")
End If
If ComboBox1.SelectedIndex = 2 Then
ListBox1.Items.Clear()
ListBox1.Items.Add("DBMS")
ListBox1.Items.Add("C++")
ListBox1.Items.Add("CGR")
End If
If ComboBox1.SelectedIndex = 3 Then
ListBox1.Items.Clear()
ListBox1.Items.Add("DCC")
ListBox1.Items.Add("GAD")
ListBox1.Items.Add("SEN")
End If
If ComboBox1.SelectedIndex = 4 Then
ListBox1.Items.Clear()
ListBox1.Items.Add("AJP")
ListBox1.Items.Add("ACN")
ListBox1.Items.Add("PHP")
End If
End Sub
End Class
Output