Results 1 to 4 of 4

Thread: Help With Menu

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    11

    Help With Menu

    Hi I am making a menu and 1 of the functions of menu is a button which you click is called Colour when you click Colour the background of the form is suppose to change. I want it to be 1 of 3 colours every time but it seems to only want to be 1 colour the way its programmed can anyone help me so it is random here is what i have so far.

    Private Sub mnuColour_Click()
    Form.BackColor = vbRed
    Form.BackColor = vbBlue
    Form.BackColor = vbGreen
    End Sub

    The colouyr it wants to be is vbgreen i however want it to be 1 of the three not the same green everytime you click it.

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Help With Menu

    Try this:
    VB Code:
    1. Option Explicit
    2.     Private colours(2) As Long
    3.  
    4. Private Sub Form_Load()
    5.     Randomize
    6.     colours(0) = vbRed: colours(1) = vbBlue: colours(2) = vbGreen
    7. End Sub
    8.  
    9. Private Sub mnuColour_Click()
    10.     Me.BackColor = colours(CInt(Rnd() * 2))
    11. End Sub

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help With Menu

    Quote Originally Posted by sh4d0w
    The colouyr it wants to be is vbgreen i however want it to be 1 of the three not the same green everytime you click it.
    Are you saying that everytime Green comes up you want it to be a different shade of green?

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    11

    Re: Help With Menu

    Thank you very much that helped alot it worked!

Posting Permissions

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



Click Here to Expand Forum to Full Width