0% found this document useful (0 votes)
12 views

Program 1 To 3

The document contains code examples for three VB.NET programs: one to display student details using controls, another to change the background color using trackbars and scrollbars, and a calculator application.

Uploaded by

David Billlaa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Program 1 To 3

The document contains code examples for three VB.NET programs: one to display student details using controls, another to change the background color using trackbars and scrollbars, and a calculator application.

Uploaded by

David Billlaa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

1. VB.

NET PROGRAM FOR GET STUDENT DETAILS USING ALL CONTROLS:

Public Class Form1

Private Sub Display_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Display.Click

Me.DataGridView1.Rows.Add(TextBox1.Text, TextBox2.Text,
DateTimePicker1.Text, TextBox4.Text, ComboBox1.Text,
TextBox6.Text)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.Text = ""

TextBox2.Text = ""

DateTimePicker1.Text = ""

TextBox4.Text = ""

ComboBox1.Text = ""

TextBox6.Text = ""

End Sub

End Class
OUTPUT:
*********
PROGRAM 2: CHANGE THE BACKGROUND COLOR USING TRACK BAR
AND SCROLLBAR CONTROLS IN VB.NET

Public Class Form1

Private Sub TrackBar1_Scroll(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles TrackBar1.Scroll

Me.BackColor = Color.FromArgb(TrackBar1.Value,
TrackBar2.Value, TrackBar3.Value)
End Sub

Private Sub TrackBar2_Scroll(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles TrackBar2.Scroll

Me.BackColor = Color.FromArgb(TrackBar1.Value,
TrackBar2.Value, TrackBar3.Value)
End Sub

Private Sub TrackBar3_Scroll(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles TrackBar3.Scroll

Me.BackColor = Color.FromArgb(TrackBar1.Value,
TrackBar2.Value, TrackBar3.Value)
End Sub

Private Sub HScrollBar1_Scroll(ByVal sender As System.Object,


ByVal e As System.Windows.Forms.ScrollEventArgs) Handles
HScrollBar1.Scroll

Me.BackColor = Color.FromArgb(HScrollBar1.Value,
HScrollBar2.Value, HScrollBar3.Value)
End Sub
Private Sub HScrollBar2_Scroll(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.ScrollEventArgs) Handles
HScrollBar2.Scroll

Me.BackColor = Color.FromArgb(HScrollBar1.Value,
HScrollBar2.Value, HScrollBar3.Value)
End Sub

Private Sub HScrollBar3_Scroll(ByVal sender As System.Object,


ByVal e As System.Windows.Forms.ScrollEventArgs) Handles
HScrollBar3.Scroll

Me.BackColor = Color.FromArgb(HScrollBar1.Value,
HScrollBar2.Value, HScrollBar3.Value)

End Sub
End Class
OUTPUT
*********
PROGRAM 3: CALCULATOR APPLICATION IN VB.NET

Public Class Form1


Dim firstnum As Decimal
Dim secondnum As Decimal
Dim operations As Integer
Dim operator_Selector As Boolean = False

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "1"
Else
TextBox1.Text = "1"
End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "2"
Else
TextBox1.Text = "2"
End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "3"
Else
TextBox1.Text = "3"
End If

End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "4"
Else
TextBox1.Text = "4"
End If

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "5"
Else
TextBox1.Text = "5"
End If

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button7.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "6"
Else
TextBox1.Text = "6"
End If

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button9.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "7"
Else
TextBox1.Text = "7"
End If

End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "8"
Else
TextBox1.Text = "8"
End If

End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button11.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "9"
Else
TextBox1.Text = "9"
End If

End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button14.Click

If TextBox1.Text <> " 0" Then


TextBox1.Text += "0"
End If

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click

firstnum = TextBox1.Text
TextBox1.Text = "0"
operator_Selector = True
operations = 1 '=+

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button8.Click

firstnum = TextBox1.Text
TextBox1.Text = "0"
operator_Selector = True
operations = 2 '=-

End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button12.Click

firstnum = TextBox1.Text
TextBox1.Text = "0"
operator_Selector = True
operations = 3 '=*

End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button16.Click

firstnum = TextBox1.Text
TextBox1.Text = "0"
operator_Selector = True
operations = 4 '=/

End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button13.Click

TextBox1.Text = "0"
End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button15.Click

If TextBox1.Text <> "0" Then


TextBox1.Text += "."
End If

End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button17.Click

If operator_Selector = True Then


secondnum = TextBox1.Text
If operations = 1 Then
TextBox1.Text = firstnum + secondnum
End If
If operations = 2 Then
TextBox1.Text = firstnum - secondnum
End If
If operations = 3 Then
TextBox1.Text = firstnum * secondnum
End If
If operations = 4 Then
TextBox1.Text = firstnum / secondnum
End If
End If

End Sub

End Class
OUTPUT
**********

You might also like