Practical No.
Imports System
Module Program
Sub Main(args As String())
Dim a As Integer = 1
While (a < 20)
Console.WriteLine("value of a " & a)
a = a + 1
End While
Console.ReadLine()
End Sub
End Module
Imports System
Module Program
Sub Main(args As String())
Dim a As Integer = 1
Console.WriteLine("value of a " & a)
Do
a = a + 1
Console.WriteLine("value of a " & a)
Loop While (a < 20)
Console.ReadLine()
End Sub
End Module
Practical No.6
Imports System
Module Program
Sub Main(args As String())
Dim num, i As Integer
Dim b As Boolean
num=1
Console.WriteLine(" Prime Number From 1 to 100 =")
b = True
While num <= 100
b = True
i = 2
While i < num
If num Mod i = 0 Then
b = False
GoTo break
End If
i += 1
End While
break: If b Then
Console.WriteLine(num)
End If
num += 1
End While
Console.ReadLine()
End Sub
End Module
Imports System
Module Program
Sub Main(args As String())
Dim num As Integer = 1
While num <= 50
If num Mod 2 = 0 Then
Console.WriteLine("Even number: " & num)
Else
Console.WriteLine("Odd number: " & num)
End If
num = num + 1
End While
Console.ReadLine()
End Sub
End Module
Practical No.2
'User defined namespace
Namespace MyColor
Public Class Color
Sub color()
Console.WriteLine("in user defined namespace")
End Sub
End Class
End Namespace
Module Program
Dim c As New MyColor.Color
Sub Main(args As String())
c.color()
Console.ReadLine()
End Sub
End Module
'System defined namespace
Imports System.Drawing
Imports System.Windows
Module Program
Public Class Msg
Sub message()
Console.WriteLine("in system defined namespace")
End Sub
End Class
Sub Main(args As String())
Dim m As New Msg
m.message()
Console.ReadLine()
End Sub
End Module
Experiment.5
Imports System
Module Program
Sub Main(args As String())
Dim grade As Char
Console.WriteLine("Enter your Grades !!!")
grade = Console.ReadLine()
Select Case grade
Case "A", "a"
Console.WriteLine("Distinction !!!")
Case "B", "b"
Console.WriteLine("First Class !!!")
Case "C", "c"
Console.WriteLine("Second Class !!!")
Case "D", "d"
Console.WriteLine("Fail !!!")
Case Else
Console.WriteLine("Not a valid Grade.")
End Select
End Sub
End Module
Imports System
Module Program
Sub Main(args As String())
Dim n As Char
Console.WriteLine("Enter a Letter !!!")
n = Console.ReadLine()
Select Case n
Case "A", "a"
Console.WriteLine("The entered letter is a vowel")
Case "E", "e"
Console.WriteLine("The entered letter is a vowel")
Case "I", "i"
Console.WriteLine("The entered letter is a vowel")
Case "O", "o"
Console.WriteLine("The entered letteris a vowel")
Case "U", "u"
Console.WriteLine("The entered letter is a vowel")
Case Else
Console.WriteLine("The entered letter is a not vowel or it is not a character")
End Select
End Sub
End Module
Imports System
Module Program
Sub Main(args As String())
Dim a, b, r As Double
Dim operation As Char
Console.WriteLine("Enter two numbers !!!")
a = Console.ReadLine()
b = Console.ReadLine()
Console.WriteLine("Enter operation to be performed !!!")
operation = Console.ReadLine()
Select Case operation
Case "ADD", "add"
r=a+b
Console.WriteLine("Addition is " & r)
Case "SUB", "sub"
r=a-b
Console.WriteLine("Subtraction is " & r)
Case "MUL", "mul"
r=a*b
Console.WriteLine("Multiplication is " & r)
Case "DIV", "div"
r=a/b
Console.WriteLine("Division is " & r)
Case Else
Console.WriteLine("Enter the operation correctly !!!")
End Select
End Sub
End Module
Experiment.8
Public Class Form1
Private Sub
Button1_Click(sender As
Object, e As EventArgs)
Handles Button1.Click
MsgBox("Submitted
!!!")
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs)
Handles MyBase.Load
Dim b As New Button
b.Text = "BUTTON"
Me.Controls.Add(b)
End Sub
End Class
Imports System.DirectoryServices
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = System.Drawing.Color.Pink
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, r As Integer
a = TextBox1.Text
b = TextBox2.Text
r=a+b
MsgBox("Addition is " & r)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim a, b, r As Integer
a = TextBox1.Text
b = TextBox2.Text
r=a-b
MsgBox("Subtraction is " & r)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim a, b, r As Integer
a = TextBox1.Text
b = TextBox2.Text
r=a*b
MsgBox("Multiplication is " & r)
End Sub
Private Sub Button4_Click(sender As
Object, e As EventArgs) Handles
Button4.Click
Dim a, b, r As Integer
a = TextBox1.Text
b = TextBox2.Text
r=a/b
MsgBox("Division is " & r)
End Sub
End Class
Imports System.Drawing.Color
Public Class Form1
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles
Label1.Click
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Me.BackColor = System.Drawing.Color.DarkRed
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
Me.BackColor = System.Drawing.Color.SkyBlue
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Me.BackColor = System.Drawing.Color.DarkOrange
End Sub
End Class
Experiment.9
Imports System.Diagnostics.Eventing.Reader
Public Class Form1
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles
CheckBox1.CheckedChanged
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim s As String
If CheckBox1.Checked = True Then
s &= vbCrLf + CheckBox1.Text
End If
If CheckBox2.Checked = True Then
s &= vbCrLf + CheckBox2.Text
End If
If CheckBox3.Checked = True Then
s &= vbCrLf + CheckBox3.Text
End If
If CheckBox4.Checked = True Then
s &= vbCrLf + CheckBox4.Text
End If
If CheckBox5.Checked = True Then
s &= vbCrLf + CheckBox5.Text
End If
If CheckBox6.Checked = True Then
s &= vbCrLf + CheckBox6.Text
End If
If s <> Nothing Then
MsgBox("Selected items are :" & s)
Else
MsgBox("No Items selected")
End If
End Sub
End Class
Imports System.Diagnostics.Eventing.Reader
Public Class Form1
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton1.CheckedChanged
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim s As String
s = ""
If RadioButton1.Checked = True Then
s &= vbCrLf + RadioButton1.Text
ElseIf RadioButton2.Checked = True Then
s &= vbCrLf + RadioButton2.Text
End If
If s <> Nothing Then
MsgBox("Selected Gender is :" & s)
Else
MsgBox("No Gender selected !!!")
End If
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = System.Drawing.Color.Black
PictureBox1.Hide()
PictureBox2.Hide()
End Sub
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton1.CheckedChanged
PictureBox1.Show()
PictureBox2.Hide()
PictureBox1.ImageLocation = "C:\Users\sawan\Videos/bulb.on.png"
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton2.CheckedChanged
PictureBox2.Show()
PictureBox1.Hide()
PictureBox2.ImageLocation = "C:\Users\sawan\Videos/bulb.off.png"
PictureBox2.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
End Class
Imports System.Security.AccessControl
Public Class Form1
Private Sub Form1_Load(sender As Object, e As
EventArgs) Handles MyBase.Load
Me.BackColor = System.Drawing.Color.Silver
End Sub
Private Sub RadioButton1_CheckedChanged(sender As
Object, e As EventArgs) Handles
RadioButton1.CheckedChanged
Label1.ForeColor = Color.Red
End Sub
Private Sub RadioButton2_CheckedChanged(sender As
Object, e As EventArgs) Handles
RadioButton2.CheckedChanged
Label1.ForeColor = Color.Blue
End Sub
Private Sub RadioButton3_CheckedChanged(sender As
Object, e As EventArgs) Handles
RadioButton3.CheckedChanged
Label1.ForeColor = Color.Green
End Sub
End Class
Experiment.10
Public Class Form1
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
listbox1.SelectedIndexChanged
End Sub
Private Sub bu_Click(sender As Object, e As
EventArgs) Handles Button4.Click
listbox1.Items.Add(TextBox1.Text)
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles Button1.Click
listbox1.Items.Remove(listbox1.SelectedItem)
End Sub
Private Sub Button2_Click(sender As Object,
e As EventArgs) Handles Button2.Click
ComboBox1.Items.Add(TextBox3.Text)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
ComboBox1.Items.Remove(ComboBox1.SelectedItem)
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim s As String
For Each SelectedItem In ListBox1.SelectedItems
s = s + SelectedItem.ToString() + " , "
Next
MessageBox.Show("Your selected subjects are : " + s)
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
ComboBox1.SelectedItem.ToString()
MessageBox.Show("Selected college is : " +
ComboBox1.SelectedItem)
End Sub
End Class
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 Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
ComboBox1.Items.Add(TextBox2.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
ComboBox1.Items.Remove(ComboBox1.SelectedItem)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
MessageBox.Show("Subjects selected from listbox are submitted !!!")
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
MessageBox.Show("Subjects selected from combobox are submitted !!!")
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = System.Drawing.Color.Pink
End Sub
End Class
Experiment.11
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = System.Drawing.Color.Gray
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
Me.Panel1.BackColor = Drawing.Color.Red
End Sub
Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click
Me.Panel1.BackColor = Drawing.Color.Blue
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.ImageLocation = "C:\Users\BG-PC\Downloads\vk.18.jfif"
PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
Me.BackColor = Color.SkyBlue
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Panel1.BackColor = Color.Orange
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Panel2.BackColor = Color.White
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Panel3.BackColor = Color.DarkGreen
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Panel4.BackColor = Color.Brown
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = Color.SkyBlue
End Sub
End Class
Experiment.12
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TabPage1.Text = "RCB"
TabPage2.Text = "CSK"
TabPage3.Text = "MI"
Me.BackColor = System.Drawing.Color.Black
PictureBox1.ImageLocation = "C:\Users\sawan\Videos\RCB.jpg"
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox2.ImageLocation = "C:\Users\sawan\Videos\CSK.jpg"
PictureBox2.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox3.ImageLocation = "C:\Users\sawan\Videos\MI.jpg"
PictureBox3.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = System.Drawing.Color.White
PictureBox1.ImageLocation = "C:\Users\sawan\Videos\RED.png"
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox2.ImageLocation = "C:\Users\sawan\Videos\YELLOW.png"
PictureBox2.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox3.ImageLocation = "C:\Users\sawan\Videos\GREEN.png"
PictureBox3.SizeMode = PictureBoxSizeMode.StretchImage
Timer1.Enabled = True
Timer1.Interval = 3000
PictureBox1.Visible = True
PictureBox2.Visible = False
PictureBox3.Visible = False
Label2.ForeColor = Color.Red
Label2.Text = "Stop !!!"
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If PictureBox1.Visible Then
PictureBox1.Visible = False
PictureBox2.Visible = True
PictureBox3.Visible = False
If PictureBox2.Visible = True Then
Label2.ForeColor = Color.Yellow
Label2.Text = "Wait !!!"
End If
ElseIf PictureBox2.Visible Then
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = True
If PictureBox3.Visible = True Then
Label2.ForeColor = Color.Green
Label2.Text = "Go !!!"
End If
ElseIf PictureBox3.Visible Then
PictureBox1.Visible = True
PictureBox2.Visible = False
PictureBox3.Visible = False
If PictureBox1.Visible = True Then
Label2.ForeColor = Color.Red
Label2.Text = "Stop !!!"
End If
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Start()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub
End Class
Experiment.7
Imports System
Module Program
Dim arr() As Integer = {10, 11, 12}
Dim i, j As Integer
Sub Main(args As String())
Console.WriteLine("Using for loop :")
For i = 0 To 2
Console.WriteLine(arr(i))
Next
Console.WriteLine("Using for each loop :")
For Each j In arr
Console.WriteLine(j)
Next
Console.ReadLine()
End Sub
End Module
Imports System
Module Program
Sub Main(args As String())
Dim r, sum, t, min As Integer
For min = 1 To 500
Console.WriteLine("Armstrong Numbers are :")
While min <= 500
t = min
sum = 0
While t <> 0
r = t Mod 10
sum += +r * r * r
t = t \ 10
End While
If sum = min Then
Console.WriteLine(min)
End If
min += 1
End While
Next
Console.ReadLine()
End Sub
End Module