+ Reply to Thread
Results 1 to 5 of 5

A simple game in Visual Basic

  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    1

    Lightbulb A simple game in Visual Basic

    Hello everyone!
    I have to create a simple game in Excel 2010 VBA using UserForm that contains 49 buttons and looks like this:
    9jdnzj5xb564fc25jwy.jpg
    When you press on one of the button, each one around (up, down, left, right) changes from black to yellow. The goal is to get all these blocks yellow. Please help!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,530

    Re: A simple game in Visual Basic

    Welcome to the Forum!

    The color palette for buttons on a user form is very limited. You cannot make them yellow. There are other ways around this but I would use a worksheet instead of a userform, and use the SelectionChange event to detect when a cell is clicked. Everything else about this problem is also easier if using cells on a worksheet.

    Is this a homework assignment?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: A simple game in Visual Basic

    Quote Originally Posted by 6StringJazzer View Post
    The color palette for buttons on a user form is very limited. You cannot make them yellow.
    Sure you can, here's a starter for ten. I'll leave figuring out the initial set up to you - I'm not doing all the work!
    Userform1 Code:

    Class1 Code:

    EDIT: Hmmm, I posted the code for this, but I think 6String is right, I think this is a homework assignment.

    Why not post your code/approach and we can comment on it
    Last edited by Kyle123; 10-25-2012 at 04:10 PM.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,530

    Re: A simple game in Visual Basic

    Quote Originally Posted by Kyle123 View Post
    Sure you can
    Hmm, maybe you can, I never actually tried. I was just thinking of the dialog box in Properties to set the background color. Maybe you can set it to any color even though that dialog does not give access to entire Excel color palette.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: A simple game in Visual Basic

    If you click on back color, there is the scroll down list with all the rubbish colours, but there's also a tab at the top which allows you to pick from far more

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1