Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating names

Status
Not open for further replies.

Bvisual

Programmer
Jul 1, 2005
35
0
0
BE
hello there

i have some buttons when i press one of them the backcollor has to change to the selected coller

i chose the names like K1 , K2 , K3

now how do i make it like this
Code:
private function ChangeBackColor()

dim ClickedButton as button

select case Color
case 1           'chose coler nr1
ClickedButton.BackColor = System.Drawing.Color.FromArgb(255, 255, 255, 192)

end select
end function

all is put in a function
this fuction will be called in diffrent buttonclick events how make this work

thx
 
Try something like:

Code:
 Private [b]Sub[/b] ChangeBackColor(ByVal ClickedButton As Button)

    Select Case ClickedButton.Name
      Case "K1"
        ClickedButton.BackColor = Color.DarkTurquoise
      Case "K2"
        ClickedButton.BackColor = Color.Gold
      Case "K3"
        ClickedButton.BackColor = Color.Lavender
    End Select

  End Sub


 Private Sub K1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles K1.Click

    ChangeBackColor(K1)

  End Sub

You don't need a function becauise you are not returning a value to the caling routine.

Hope this helps

[vampire][bat]
 
thats what i did to fix it

thx but found it already :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top