Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Creating Attractive Buttons in Visual Basic.Net(VB.Net)

Author: DevASP
Download Source Code : 523_Atractive_buttons.zip

In this article i will try to explain you how to make buttons of different style in Visual Basic.Net (VB.Net)

Create new application using VB.Net and drag twelve buttons, three labels, open file dialog control and a timer control on the from

 

Create a following global variable

 

Dim flag As Boolean = False

 

Now double click on the button1 and write the following code on button click event

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Button1.FlatStyle = FlatStyle.Flat

        Button1.ForeColor = Color.Yellow

        Button1.BackColor = Color.Navy

        Button1.Text = "OK"

End Sub

 

Write the following code on button2 click event

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Button2.FlatStyle = FlatStyle.Flat

        Button2.ForeColor = Color.Yellow

        Button2.BackColor = Color.Navy

        Button2.Text = "OK"

End Sub

 

Write the following code on button3 click event

 

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Button3.FlatStyle = FlatStyle.Flat

        Button3.ForeColor = Color.Yellow

        Button3.BackColor = Color.Navy

        Button3.Text = "OK"

End Sub

 

Write the following code on button4 click event

 

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Button4.FlatStyle = FlatStyle.Flat

        Button4.ForeColor = Color.Yellow

        Button4.BackColor = Color.Navy

        Button4.Text = "OK"

End Sub

 

Write the following code on button5 click event

 

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

        Button5.FlatStyle = FlatStyle.Flat

        Button5.ForeColor = Color.Yellow

        Button5.BackColor = Color.Navy

        Button5.Text = "OK"

End Sub

 

Write the following code on button6 click event

 

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

        Button6.FlatStyle = FlatStyle.Flat

        Button6.ForeColor = Color.Yellow

        Button6.BackColor = Color.Navy

        Button6.Text = "OK"

End Sub

 

Write the following code on button7 click event

 

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

        Button7.FlatStyle = FlatStyle.Flat

        Button7.ForeColor = Color.Yellow

        Button7.BackColor = Color.Navy

        Button7.Text = "OK"

End Sub

 

Write the following code on button8 click event

 

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

        Button8.FlatStyle = FlatStyle.Flat

        Button8.ForeColor = Color.Yellow

        Button8.BackColor = Color.Navy

        Button8.Text = "OK"

End Sub

 

Write the following code on reset button click event

 

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

        Timer1.Enabled = False

 

        Button1.Image = Button9.Image

        Button2.Image = Button9.Image

        Button3.Image = Button9.Image

        Button4.Image = Button9.Image

        Button5.Image = Button9.Image

        Button6.Image = Button9.Image

        Button7.Image = Button9.Image

        Button8.Image = Button9.Image

 

        Button1.FlatStyle = FlatStyle.System

        Button2.FlatStyle = FlatStyle.System

        Button3.FlatStyle = FlatStyle.System

        Button4.FlatStyle = FlatStyle.System

        Button5.FlatStyle = FlatStyle.System

        Button6.FlatStyle = FlatStyle.System

        Button7.FlatStyle = FlatStyle.System

        Button8.FlatStyle = FlatStyle.System

 

        Button1.Text = "Button1"

        Button2.Text = "Button2"

        Button3.Text = "Button3"

        Button4.Text = "Button4"

        Button5.Text = "Button5"

        Button6.Text = "Button6"

        Button7.Text = "Button7"

        Button8.Text = "Button8"

 

End Sub

 

Write the following code on Start button click event

 

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

        Button1.Image = Button9.Image

        Button2.Image = Button9.Image

        Button3.Image = Button9.Image

        Button4.Image = Button9.Image

        Button5.Image = Button9.Image

        Button6.Image = Button9.Image

        Button7.Image = Button9.Image

        Button8.Image = Button9.Image

        Timer1.Enabled = True

    End Sub

 

Write the following code on Stop button click event

 

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click

        Timer1.Enabled = False

    End Sub 

 

Write the following code on Browse button click event

 

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

 

        Dim open As OpenFileDialog

        open = New OpenFileDialog

        open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp"

        If open.ShowDialog() = DialogResult.OK Then

            Button1.Image = Image.FromFile(open.FileName)

            Button2.Image = Image.FromFile(open.FileName)

            Button3.Image = Image.FromFile(open.FileName)

            Button4.Image = Image.FromFile(open.FileName)

            Button5.Image = Image.FromFile(open.FileName)

            Button6.Image = Image.FromFile(open.FileName)

            Button7.Image = Image.FromFile(open.FileName)

            Button8.Image = Image.FromFile(open.FileName)

 

            Button1.Text = ""

            Button2.Text = ""

            Button3.Text = ""

            Button4.Text = ""

            Button5.Text = ""

            Button6.Text = ""

            Button7.Text = ""

            Button8.Text = ""

 

        End If

        Invalidate()

        Button1.Refresh()

 

End Sub

 

Write the following code on Timer Tick event

 

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        If flag = False Then

            flag = True

            Button1.FlatStyle = FlatStyle.Flat

            Button1.ForeColor = Color.Red

            Button1.BackColor = Color.White

            Button1.Text = "OK"

 

            Button2.FlatStyle = FlatStyle.Flat

            Button2.ForeColor = Color.Red

            Button2.BackColor = Color.White

            Button2.Text = "OK"

 

            Button3.FlatStyle = FlatStyle.Flat

            Button3.ForeColor = Color.Red

            Button3.BackColor = Color.White

            Button3.Text = "OK"

 

            Button4.FlatStyle = FlatStyle.Flat

            Button4.ForeColor = Color.Red

            Button4.BackColor = Color.White

            Button4.Text = "OK"

 

            Button5.FlatStyle = FlatStyle.Flat

            Button5.ForeColor = Color.Red

            Button5.BackColor = Color.White

            Button5.Text = "OK"

 

            Button6.FlatStyle = FlatStyle.Flat

            Button6.ForeColor = Color.Red

            Button6.BackColor = Color.White

            Button6.Text = "OK"

 

            Button7.FlatStyle = FlatStyle.Flat

            Button7.ForeColor = Color.Red

            Button7.BackColor = Color.White

            Button7.Text = "OK"

 

            Button8.FlatStyle = FlatStyle.Flat

            Button8.ForeColor = Color.Red

            Button8.BackColor = Color.White

            Button8.Text = "OK"

        Else

            flag = False

 

            Button1.FlatStyle = FlatStyle.Flat

            Button1.ForeColor = Color.White

            Button1.BackColor = Color.Red

            Button1.Text = "OK"

 

            Button2.FlatStyle = FlatStyle.Flat

            Button2.ForeColor = Color.White

            Button2.BackColor = Color.Red

            Button2.Text = "OK"

 

            Button3.FlatStyle = FlatStyle.Flat

            Button3.ForeColor = Color.White

            Button3.BackColor = Color.Red

            Button3.Text = "OK"

 

            Button4.FlatStyle = FlatStyle.Flat

            Button4.ForeColor = Color.White

            Button4.BackColor = Color.Red

            Button4.Text = "OK"

 

            Button5.FlatStyle = FlatStyle.Flat

            Button5.ForeColor = Color.White

            Button5.BackColor = Color.Red

            Button5.Text = "OK"

 

            Button6.FlatStyle = FlatStyle.Flat

            Button6.ForeColor = Color.White

            Button6.BackColor = Color.Red

            Button6.Text = "OK"

 

            Button7.FlatStyle = FlatStyle.Flat

            Button7.ForeColor = Color.White

            Button7.BackColor = Color.Red

            Button7.Text = "OK"

 

            Button8.FlatStyle = FlatStyle.Flat

            Button8.ForeColor = Color.White

            Button8.BackColor = Color.Red

            Button8.Text = "OK"

 

        End If

    End Sub

Article Comments
very very impressive.i am a new beginner in asp.net with vb.net.please guide me how will i find definite codes on demand in google or something else.please refer .me

Posted on 3/21/2007 7:51:06 PM by Arnav Chattopadhyay

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Creating Flash File Player in Visual Basic.Net (VB.Net)

Disclaimer - Privacy
© 2002-2017 DevASP.net