|
-
Jan 29th, 2007, 02:25 PM
#1
Thread Starter
Junior Member
[RESOLVED] VB6 Button Backcolor
I am going nuts and I feel so stupid for not being able to figure this out!
I have four buttons, A B C and D, and when you click on A, I want the backcolor of the button to change. Then when you click on B, I want A to change back to grey, and for B's backcolor to change. Could anyone help me out with this?
-
Jan 29th, 2007, 02:28 PM
#2
Re: VB6 Button Backcolor
Welcome to the forms. 
What code do you have in your button clicks now?
Are they stand alone buttons or in an array?
-
Jan 29th, 2007, 02:30 PM
#3
Re: VB6 Button Backcolor
Add one command button
set the STYLE = Graphical
now copy the button and paste it 3 times... YES, you want a control array
VB Code:
Private Sub Command1_Click(Index As Integer)
For x = 0 To Command1.UBound
If x = Index Then
Command1(x).BackColor = &HFF& 'Red
Else
Command1(x).BackColor = &H8000000F 'Button Face
End If
Next
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 29th, 2007, 03:10 PM
#4
Thread Starter
Junior Member
Re: VB6 Button Backcolor
These are stand alone buttons... I cannot use a control array...
-
Jan 29th, 2007, 03:18 PM
#5
Re: VB6 Button Backcolor
ok.. fancy way:
VB Code:
Private Sub Command1_Click()
SetBGColor Command1
End Sub
Private Sub Command2_Click()
SetBGColor Command2
End Sub
Private Sub Command3_Click()
SetBGColor Command3
End Sub
Private Sub Command4_Click()
SetBGColor Command4
End Sub
Private Sub SetBGColor(btn As CommandButton)
Dim ctl As Control
btn.BackColor = &HFF
For Each ctl In Me.Controls
If TypeOf ctl Is CommandButton Then
If ctl <> btn Then
ctl.BackColor = &H8000000F
End If
End If
Next
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 29th, 2007, 03:32 PM
#6
Thread Starter
Junior Member
Re: VB6 Button Backcolor
Thats VB.NET... I'm looking for VB 6
-
Jan 29th, 2007, 03:34 PM
#7
Re: VB6 Button Backcolor
look again. thats VB6
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 29th, 2007, 03:34 PM
#8
Thread Starter
Junior Member
Re: VB6 Button Backcolor
Very sorry static. Thank you so much.
-
Jan 29th, 2007, 03:45 PM
#9
Re: VB6 Button Backcolor
No problem!!
now that its saolved.. please go to thread tools and click mark thread resolved
Thanks!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|