CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2001
    Posts
    65

    How can I make this dice work?

    Hi,

    I am making a game in VB. I have an image box which will be a dice (ImgDice) - which the player can use by clicking a button marked "roll". I have 6 other image boxes - one for each number with bitmaps loaded in - they are called ImgDice1 .. through to ImgDice6.

    What I want to know is the code that I can attach to the `roll` button o RANDOMLY load up one of the dice numbers, but I want it to be completely random.

    Any code for this...

    Thanks

    Mark


  2. #2
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    Re: How can I make this dice work?

    You should better make an imagebox array with indexes from 0 to 5.
    then write the following:

    private Sub Form_Load()
    Randomize
    End Sub

    private Sub cmdRoll_Click()
    imgDice(CInt(Rnd() * 6 )).Visible=true
    End Sub



    instead of the Visible=True you can show the image you want in any other way.

    ----------
    The @host is everywhere!
    ----------

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

Featured