0% found this document useful (0 votes)
132 views22 pages

Nishant Orignal Copy

The document contains code snippets for designing various Windows form applications using Visual Basic .NET. The applications include changing form color using buttons, using timers to change color automatically, using track bars and numeric up-downs to control progress bars, calculating factorials, generating restaurant bills based on menu selections, connecting to an Access database, and using menus to change form size and color.

Uploaded by

Nishant Kumaria
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views22 pages

Nishant Orignal Copy

The document contains code snippets for designing various Windows form applications using Visual Basic .NET. The applications include changing form color using buttons, using timers to change color automatically, using track bars and numeric up-downs to control progress bars, calculating factorials, generating restaurant bills based on menu selections, connecting to an Access database, and using menus to change form size and color.

Uploaded by

Nishant Kumaria
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

Q1. Design an application to change color of the form.

(Output)
Q1. Design an application to change color of the form.

Public Class Form1

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


System.EventArgs) Handles Button1.Click
Me.BackColor = Color.Red
End Sub

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


System.EventArgs) Handles Button2.Click
Me.BackColor = Color.Blue
End Sub

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


System.EventArgs) Handles Button3.Click
Me.BackColor = Color.Yellow
End Sub

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


System.EventArgs) Handles Button4.Click
Me.BackColor = Color.Green
End Sub

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


System.EventArgs) Handles Button5.Click
End
End Sub

End Class
Q5. Design an application to make use of timer control to change color
of the form.

(Output)
Q5. Design an application to make use of timer control to change color
of the form.

Public Class Form1

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


System.EventArgs) Handles Timer1.Tick
Me.BackColor = Color.Purple
End Sub

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


System.EventArgs) Handles Button1.Click
Timer2.Enabled = True
End Sub

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


System.EventArgs) Handles Button3.Click
Timer1.Enabled = True
Timer3.Enabled = True
End Sub

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


System.EventArgs) Handles Timer2.Tick
Beep()
End Sub

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


System.EventArgs) Handles Button2.Click
Timer2.Enabled = False
End Sub

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


System.EventArgs) Handles Timer3.Tick
Me.BackColor = Color.Cyan
End Sub

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


System.EventArgs) Handles Button4.Click
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
End
End Sub

End Class
Q6. Design an application, using track bar, (numeric up-down).

(Output)
Q6. Design an application, using track bar, (numeric up-down).

Public Class Form1

Private Sub NumericUpDown1_ValueChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
NumericUpDown1.ValueChanged

TrackBar1.Value = NumericUpDown1.Value
ProgressBar1.Value = NumericUpDown1.Value

End Sub

End Class
Q3. Design an application to compute the factorial of the number.

(Output)
Q3. Design an application to compute the factorial of the number.

Public Class Form1

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


System.EventArgs) Handles Button1.Click
Dim i, res As Integer
res = 1
For i = 1 To TextBox1.Text
res = res * i
Next
MsgBox(res)
End Sub

End Class
Q2. Design an application to represent menu of the restraunt, display
the rate list & generate the bill.

(Output)
Q2. Design an application to represent menu of the restraunt, display
the rate list & generate the bill.

Public Class Form1

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


System.EventArgs) Handles Button1.Click

Dim a As Integer
a=0
If(Chk1.checked=True) Then
a=a+55
End If

If(Chk2.checked=True) Then
a=a+48
End If

If(Chk3.checked=True) Then
a=a+100
End If

If(Chk4.checked=True) Then
a=a+40
End If

If(Chk5.checked=True) Then
a=a+80
End If

If(Chk6.checked=True) Then
a=a+60
End If

If(Chk7.checked=True) Then
a=a+55
End If

If(Chk8.checked=True) Then
a=a+48
End If
If(Chk9.checked=True) Then
a=a+80
End If

If(Chk10.checked=True) Then
a=a+100
End If

If(Chk11.checked=True) Then
a=a+40
End If

If(Chk12.checked=True) Then
a=a+60
End If

If(Chk13.checked=True) Then
a=a+55
End If

If(Chk14.checked=True) Then
a=a+48
End If

If(Chk15.checked=True) Then
a=a+80
End If

If(Chk16.checked=True) Then
a=a+100
End If

If(Chk17.checked=True) Then
a=a+40
End If

If(Chk18.checked=True) Then
a=a+60
End If

Label1.Text=a
Msgbox(“Your Bill is: “+Label1.Text)
End Sub
Q9. Design an application to show the connectivity with the database…
(ms..access)

(Output)
Q9. Design an application to show the connectivity with the database…
(ms..access)

Imports System.Data.OleDb
Public Class Form1

Inherits System.Windows.Forms.Form
Dim MyConnection As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Nis.mdb")
Dim MyCommand
Dim e As Exception
Dim MyCommand2
Dim MyReader As OleDbDataReader
Dim MyReader2 As OleDbDataReader
Dim dbset As New DataSet

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


System.EventArgs) Handles Button1.Click
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim ea As Integer
a = TextBox4.Text
b = TextBox5.Text
c = TextBox6.Text
d = TextBox7.Text
ea = a + b + c + d
TextBox8.Text = ea
MyConnection.Open()
MyCommand = New OleDbCommand("INSERT INTO student VALUES('" &
TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "',' " &
TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "',' " &
TextBox7.Text & "','" & TextBox8.Text & "')", MyConnection)
MyCommand.ExecuteNonQuery()
MyConnection.Close()
MyCommand.dispose()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
MyConnection.Open()
Try
MyCommand = New OleDbCommand("UPDATE student SET st_name
='" & TextBox1.Text & "',st_course = '" & TextBox3.Text & "',cn = '" &
TextBox4.Text & "', linux = '" & TextBox5.Text & "', dotnet = '" & TextBox6.Text
& "', ecommerce = '" & TextBox7.Text & "' WHERE st_rollno = '" & TextBox2.Text
& "'", MyConnection)
MyCommand.ExecuteNonQuery()
Catch c As Exception
MsgBox(c.ToString)
End Try
MyConnection.Close()
MyCommand.dispose()
End Sub

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


System.EventArgs) Handles Button4.Click
MyConnection.Open()
MyCommand = New OleDbCommand("SELECT * FROM student WHERE
st_rollno ='" & TextBox9.Text & "'", MyConnection)
MyReader = MyCommand.ExecuteReader()
While MyReader.Read
TextBox1.Text = MyReader("st_name")
TextBox2.Text = MyReader("st_rollno")
TextBox3.Text = MyReader("st_course")
TextBox4.Text = MyReader("cn")
TextBox5.Text = MyReader("linux")
TextBox6.Text = MyReader("dotnet")
TextBox7.Text = MyReader("ecommerce")
TextBox8.Text = MyReader("total")
End While
MyConnection.Close()
MyReader.Close()
MyCommand.dispose()
End Sub

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


System.EventArgs) Handles Button2.Click
MyConnection.Open()
MyCommand = New OleDbCommand("DELETE * FROM student WHERE
st_rollno ='" & TextBox9.Text & "'", MyConnection)
MyCommand.ExecuteNonQuery()
MyConnection.Close()
MyCommand.dispose()
End Sub

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


System.EventArgs) Handles MyBase.Load

End Sub

End Class
Q8. Design an application having menu <size, color> to reflect
corresponding changes to the form.

(Output)
Q8. Design an application having menu <size, color> to reflect
corresponding changes to the form.

Public Class Form1

Private Sub SmallToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
SmallToolStripMenuItem.Click
ActiveForm.Width = 500
ActiveForm.Height = 500
End Sub

Private Sub RedToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
RedToolStripMenuItem.Click
Me.BackColor = Color.Red
End Sub

Private Sub BlueToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
BlueToolStripMenuItem.Click
Me.BackColor = Color.Blue
End Sub

Private Sub MiddleToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
MiddleToolStripMenuItem.Click
ActiveForm.Height = 700
ActiveForm.Width = 700
End Sub

Private Sub LargeToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
LargeToolStripMenuItem.Click
ActiveForm.Height = 1000
ActiveForm.Width = 1000
End Sub

End Class
Q4. Design an application Form.

(Output)
Q4. Design an application Form.

Public Class Form1

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


As System.EventArgs) Handles Button1.Click
MsgBox(TextBox1.Text + "YOUR FORM IS GET SUBMITTED")
End Sub

Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles GroupBox2.Enter
End Sub

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


As System.EventArgs) Handles Button2.Click
End
End Sub

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


As System.EventArgs) Handles Button3.Click
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
TextBox5.Text = " "
TextBox6.Text = " "
TextBox7.Text = " "
TextBox8.Text = " "
End Sub

End Class
Q7. Design a Dialogue box.

(Output)
Q7. Design a Dialogue box.

Public Class Form1

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


As System.EventArgs) Handles Button1.Click
OpenDialog.ShowDialog()
End Sub

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


As System.EventArgs) Handles Button3.Click
c1.ShowDialog()
t1.ForeColor = c1.Color
End Sub

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


As System.EventArgs) Handles Button4.Click
FontDialog1.ShowDialog()
t1.Font = FontDialog1.Font
End Sub

End Class

You might also like