VB.Net

 Experiment No- 4 1. Program for addition of two numbers

Public Class Form1

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

Button1.Click

Dim num1, num2, result As Single

num1 = Val(TextBox1.Text)

num2 = Val(TextBox2.Text)

result = num1 + num2

TextBox3.Text = result

End Sub

End Class

2. Program to calculate area and perimeter of rectangle 

Public Class Form2

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

Button1.Click

Dim length, breadth, area As Single

length = Val(TextBox1.Text)

breadth = Val(TextBox2.Text)

area = length * breadth

TextBox3.Text = area

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles

Button2.Click

Dim length, breadth, peri As Single

length = Val(TextBox1.Text)

breadth = Val(TextBox2.Text)

peri = 2 * (length + breadth)

Label3.Text = peri

End Sub

End Class


3. Program to calculate area and perimeter of circle

Public Class Form3

Private Sub Button1_Click(sender As Object, e As EventArgs)

Handles Button1.Click

Dim rad, area, peri As Single

Const pi As Single = 3.14

rad = Val(TextBox1.Text)

area = pi * rad ^ 2

peri = 2 * pi * rad

Label3.Text = area

Label5.Text = peri

End Sub

End Class 

Experiment No- 5 1. Program to decide type of number

Public Class Form6

Private Sub Button1_Click(sender As Object, e As EventArgs)

Handles Button1.Click

Dim num As Integer

num = Val(TextBox1.Text)

If num Mod 2 = 0 Then

Label2.Text = "Even"

Else

Label2.Text = "Odd"

End If

End Sub

End Class


2. Program to decide grade point


Public Class Form8

Private Sub Button1_Click(sender As Object, e As EventArgs)

Handles Button1.Click

Dim se1, se2, see, total As Integer

se1 = Val(TextBox1.Text)

se2 = Val(TextBox2.Text)

see = Val(TextBox3.Text)

total = se1 + se2 + see / 2

If see < 40 Or total < 40 Then

Label4.Text = "Fail"

ElseIf total < 45 Then

Label4.Text = "P"

ElseIf total < 50 Then

Label4.Text = "C"

ElseIf total < 60 Then

Label4.Text = "B"

ElseIf total < 70 Then

Label4.Text = "B+"

ElseIf total < 80 Then

Label4.Text = "A"

ElseIf total < 90 Then

Label4.Text = "A+"

Else

Label4.Text = "Outstanding"

End If

End Sub

End Class


3. Program to decide type of chemical

Public Class Form10

Private Sub Button1_Click(sender As Object, e As EventArgs)

Handles Button1.Click

Dim pH As Single

pH = Val(TextBox1.Text)

Select Case pH

Case Is < 0

Label2.Text = "Invalid value of pH"

Case Is < 7

Label2.Text = "Acidic"

Case 7

Label2.Text = "Neutral"

Case 7.001 To 14

Label2.Text = "Alkaline"

Case Else

Label2.Text = "Invalid value of pH"

End Select

End Sub

End Class

Experiment No- 6 1. Program to calculate sum of numbers from lower number to upper number

Public Class Form8
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim lower, upper, sum As Integer
lower = Val(TextBox1.Text)
upper = Val(TextBox2.Text)
Do While lower <= upper
sum = sum + lower
lower = lower + 1
Loop
Label3.Text = sum
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs)
Handles Button2.Click
Dim lower, upper, sum As Integer
lower = Val(TextBox1.Text)
upper = Val(TextBox2.Text)
Do Until lower > upper
sum = sum + lower
lower = lower + 1
Loop
Label4.Text = sum
End Sub
End Class

2. Program to calculate factorial of given number

Public Class Form12
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim num, fact, a As Integer
num = Val(TextBox1.Text)
a = 1
fact = 1
While a <= num
facto = facto * a
a = a + 1
End While
Label2.Text = facto
End Sub
End Class

3. Program to display multiplication table of given number

Public Class Form13
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim num, res, i As Integer
num = Val(TextBox1.Text)
TextBox2.Text = ""
For i = 1 To 10 Step 1
res = num * i
TextBox2.Text = TextBox2.Text & res & vbNewLine
Next i
End Sub
End Class

Experiment No- 7 1. Program to calculate average marks of students using array

Public Class Form18
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim i, marks(10) As Integer
Dim total, average As Single
TextBox1.Text = ""
For i = 0 To 9 Step 1
marks(i) = Val(InputBox("Enter marks"))
TextBox1.Text = TextBox1.Text & marks(i) & vbNewLine
total = total + marks(i)
Next i
average = total / 10
Label3.Text = average
End Sub
End Class


Experiment No- 8 1. Program to calculate nCr using function

Public Class Form16
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim n, r, nr, nf, rf, nrf, ncr As Integer
n = Val(TextBox1.Text)
r = Val(TextBox2.Text)
nr = n - r
nf = factorial(n)
rf = factorial(r)
nrf = factorial(nr)
ncr = nf / (rf * nrf)
Label3.Text = ncr
End Sub
Private Function factorial(ByVal num As Integer) As Integer
Dim facto As Integer
facto = 1
While num >= 1
facto = facto * num
num = num - 1
End While
Return facto
End Function
End Class


Experiment No- 9

Public Class Form16
Private Sub Timer1_Tick(sender As Object, e As EventArgs)
Handles Timer1.Tick
PictureBox1.Width = PictureBox1.Width + 1
PictureBox1.Height = PictureBox1.Height + 1
End Sub
End Class

Experiment No- 10

Public Class Form17
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
ComboBox1.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
Handles Button2.Click
ListBox1.Items.Add(ComboBox1.SelectedItem)
ComboBox1.Items.Remove(ComboBox1.SelectedItem)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs)
Handles Button3.Click
Dim i As Integer
For i = 0 To ComboBox1.Items.Count - 1 Step 1
ListBox1.Items.Add(ComboBox1.Items(i))
Next i
ComboBox1.Items.Clear()
End Sub
End Class


Experiment No- 11

Public Class Form18
Private Sub RadioButton1_Click(sender As Object, e As EventArgs)
Handles RadioButton1.Click
CheckBox1.Text = "Raymonds"
CheckBox2.Text = "Alok"
CheckBox3.Text = "Arvind"
End Sub
Private Sub RadioButton2_click(sender As Object, e As EventArgs)
Handles RadioButton2.CheckedChanged
CheckBox1.Text = "Soktas"
CheckBox2.Text = "GHCL"
CheckBox3.Text = "Reliance"
End Sub
Private Sub RadioButton3_click(sender As Object, e As EventArgs)
Handles RadioButton3.CheckedChanged
CheckBox1.Text = "Laxmi"
CheckBox2.Text = "Rieter"
CheckBox3.Text = "Zincer"
End Sub

------------------------------------------------------------------------------

Private Sub RadioButton4_click(sender As Object, e As EventArgs)
Handles RadioButton4.CheckedChanged
CheckBox1.Text = "GHCL"
CheckBox2.Text = "Indocount"
CheckBox3.Text = "BRFL"
End Sub
Private Sub RadioButton5_Click(sender As Object, e As EventArgs)
Handles RadioButton5.CheckedChanged
CheckBox1.Text = "Himatsingka"
CheckBox2.Text = "Welspun"
CheckBox3.Text = "BRFL"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim cgpa As Single
cgpa = Val(TextBox1.Text)
If cgpa >= 7 And CheckBox1.Checked = True Then
Label4.Text = CheckBox1.Text
ElseIf cgpa >= 6 And CheckBox2.Checked = True Then
Label4.Text = CheckBox2.Text
Else
Label4.Text = CheckBox3.Text
End If
End Sub
End Class


Experiment No- 12

Public Class Form19
Private Sub OpenToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles OpenToolStripMenuItem.Click
OpenFileDialog1.ShowDialog()
MsgBox("File to be opened: " & OpenFileDialog1.FileName)
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles SaveToolStripMenuItem.Click
SaveFileDialog1.ShowDialog()
MsgBox("File to be saved: " & SaveFileDialog1.FileName)
End Sub
Private Sub PrintToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles PrintToolStripMenuItem.Click
PrintDialog1.ShowDialog()
MsgBox("Printer name: " &
PrintDialog1.PrinterSettings.PrinterName)
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub BackcolorToolStripMenuItem_Click(sender As Object, e
As EventArgs) Handles BackcolorToolStripMenuItem.Click
ColorDialog1.ShowDialog()
TextBox1.BackColor = ColorDialog1.Color
End Sub
Private Sub ForecolorToolStripMenuItem_Click(sender As Object, e
As EventArgs) Handles ForecolorToolStripMenuItem.Click
ColorDialog1.ShowDialog()
TextBox1.ForeColor = ColorDialog1.Color
End Sub
Private Sub FONTToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles FONTToolStripMenuItem.Click
FontDialog1.ShowDialog()
TextBox1.Font = FontDialog1.Font
End Sub
End Class
 




Post a Comment

0 Comments