?
Solved

Easy Question

Posted on 2003-03-08
4
Medium Priority
?
172 Views
Last Modified: 2010-05-01
i have a simple game in which there are numerous command buttons that change backcolors every second. what i want, is to deduct a point from the score if the player misses clicking on a button when it is a certain color.

i want the point to be deducted as soon as the button color changes.

any ideas on the best way to accomplish this?
0
Comment
Question by:EverythingVB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Expert Comment

by:navneet77
ID: 8096886
i am not sure what is the structure of the whole game but at the point where you are changing the color can you not check if it is certain color and has not been clicked than deduct point.

like

dim hasclicked as boolean

private sub vutton_onclick()
hasclick = true
end sub


private sub changecolor()

if button.backcolor = vbred then
points = points - deduct
button.backcolor = vbblue
elseif ...
...
end if
end sub
0
 
LVL 2

Expert Comment

by:navneet77
ID: 8096890
sorry may be should be

private sub changecolor()

if button.backcolor = vbred then
  if not hasclick then
points = points - deduct
  end if
button.backcolor = vbblue
elseif ...
...
end if

  hasclick = false

end sub
0
 
LVL 2

Expert Comment

by:spauljoseph
ID: 8096966
Use this.

Private Sub cmdBtn_Click(Index as Integer)
    If cmdBtn(Index).BackColor=RGB(100,100,100) Then 'Add your color value here
        curPoints = curPoints - 1
    End If
End Sub
0
 

Accepted Solution

by:
Naylin earned 240 total points
ID: 8098065
First things first, if your command buttons aren't in a control array, you need them to be for this to work.

Next insert this into your declarations at the top of your form code:

     Private GotIt As Boolean
     
Then this in your timer event that changes the colors of your buttons:

     If Not GotIt Then
         points = points - NumPointsToSubtract
     Else
         GotIt = False
     End If

And for your click event for your buttons:

     Private Sub Command1_Click(Index As Integer)
     If Command1(Index).BackColor = vbRed Then
         GotIt = True
     End If
     End Sub

Should work as long as you aren't using colors that range the whole spectrum. If you are using more than the VB basic colors, it is just a matter of checking for the RGB values instead of the vbcolor.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question