title: Dice Game in VB.net
body: <p>I have three issues in a vb.net program I am working on. I am creating a dice game where a user can click roll and it will randomly roll and show them the pictures of the dice they rolled. They can chose how many chips they want to play and what number they are betting on. They roll three dice each go.</p>
  
  <p>Here are the issues:</p>
  
  <p>Duplicates - When the user clicks rolls and the random generated numbers, two of them are the same, it will not show one of them. It should show one of them</p>
  
  <p>Images moving into Pictureboxes - I'm trying to get the dice images to move into pictureboxes, better than just having things become visible if played.</p>
  
  <p>Picture of gui: <a href="http://i.imgur.com/Kn6Nd.png" rel="nofollow">http://i.imgur.com/Kn6Nd.png</a></p>
  
  <p>Current code: </p>
  
  <pre><code> Dim do1 As Integer = rnd.Next(1, 7)
      Dim do2 As Integer = rnd.Next(1, 7)
      Dim do3 As Integer = rnd.Next(1, 7)
      Dim do4 As Integer = rnd.Next(1, 7)
      Dim do5 As Integer = rnd.Next(1, 7)
      Dim do6 As Integer = rnd.Next(1, 7)
  
      ''Assign the appropriate image based on each die's value.
      d1.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d1)), Image)
      d2.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d2)), Image)
      d3.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d3)), Image)
      d4.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d1)), Image)
      d5.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d2)), Image)
      d6.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d3)), Image)
  
      Dim iNumber As Integer
      Dim iNumber2 As Integer
      Dim iNumber3 As Integer
  
      'purpose is to roll the dice and play the game. 
      'variables and declarations are here.
      Dim chips As Integer = 100
  
  
      If chkBet1.Checked = False And ChkBet2.Checked = False And chkBet3.Checked = False And chkBet4.Checked = False And chkBet5.Checked = False And chkBet6.Checked = False Then
          MessageBox.Show("Please select a number to play")
      Else
  
          If txtChip1.Text = "" AndAlso txtChip2.Text = "" AndAlso txtChip3.Text = "" AndAlso txtChip4.Text = "" AndAlso txtChip5.Text = "" AndAlso txtChip6.Text = "" Then
              MessageBox.Show("You must enter an amount.")
          Else
  
              'here we are randomizing the numbers for the game. 
              'iNumber = Int((6 * rnd()) + 1)
              'iNumber2 = Int((6 * rnd()) + 1)
              'iNumber3 = Int((6 * rnd()) + 1)
  
              'this will show the dice if the number generated between 1-6 is automatically chosen. 
              If iNumber = 1 Then
                  d1.Visible = True
              ElseIf iNumber = 2 Then
                  d2.Visible = True
              ElseIf iNumber = 3 Then
                  d3.Visible = True
              ElseIf iNumber = 4 Then
                  d4.Visible = True
              ElseIf iNumber = 5 Then
                  d5.Visible = True
              ElseIf iNumber = 6 Then
                  d6.Visible = True
              End If
  
              'this will show for the second dice. 
              If iNumber2 = 1 Then
                  d1.Visible = True
              ElseIf iNumber2 = 2 Then
                  d2.Visible = True
              ElseIf iNumber2 = 3 Then
                  d3.Visible = True
              ElseIf iNumber2 = 4 Then
                  d4.Visible = True
              ElseIf iNumber2 = 5 Then
                  d5.Visible = True
              ElseIf iNumber2 = 6 Then
                  d6.Visible = True
              End If
  
              'this will show for the third dice. 
              If iNumber3 = 1 Then
                  d1.Visible = True
              ElseIf iNumber3 = 2 Then
                  d2.Visible = True
              ElseIf iNumber3 = 3 Then
                  d3.Visible = True
              ElseIf iNumber3 = 4 Then
                  d4.Visible = True
              ElseIf iNumber3 = 5 Then
                  d5.Visible = True
              ElseIf iNumber3 = 6 Then
                  d6.Visible = True
              End If
  
              ''this part is for the chips that they win. If they bet one chip, and one dice rolls a one, they got two chips. 
              If do1 = 1 AndAlso chkBet1.Checked Then
                  chips = "2"
              ElseIf do2 = 2 AndAlso ChkBet2.Checked Then
                  chips = "4"
              ElseIf do3 = 3 AndAlso chkBet3.Checked Then
                  chips = "6"
              ElseIf iNumber = 4 AndAlso chkBet4.Checked Then
                  chips = "8"
              ElseIf iNumber = 5 AndAlso chkBet5.Checked Then
                  chips = "10"
              ElseIf iNumber = 6 AndAlso chkBet6.Checked Then
                  chips = "12"
              End If
  
              ''second chip possible winnings. 
              If iNumber2 = 1 AndAlso chkBet1.Checked Then
                  chips = "2"
              ElseIf iNumber2 = 2 AndAlso ChkBet2.Checked Then
                  chips = "4"
              ElseIf iNumber2 = 3 AndAlso chkBet3.Checked Then
                  chips = "6"
              ElseIf iNumber2 = 4 AndAlso chkBet4.Checked Then
                  chips = "8"
              ElseIf iNumber2 = 5 AndAlso chkBet5.Checked Then
                  chips = "10"
              ElseIf iNumber2 = 6 AndAlso chkBet6.Checked Then
                  chips = "12"
              End If
  
              'third chip possible winnings. 
              If iNumber3 = 1 AndAlso chkBet1.Checked Then
                  chips = "2"
              ElseIf iNumber3 = 2 AndAlso ChkBet2.Checked Then
                  chips = "4"
              ElseIf iNumber3 = 3 AndAlso chkBet3.Checked Then
                  chips = "6"
              ElseIf iNumber3 = 4 AndAlso chkBet4.Checked Then
                  chips = "8"
              ElseIf iNumber3 = 5 AndAlso chkBet5.Checked Then
                  chips = "10"
              ElseIf iNumber3 = 6 AndAlso chkBet6.Checked Then
                  chips = "12"
              End If
  
              'chips are added up here by all
              'chips = iNumber + chips '+ iNumber2 + iNumber3
              lblChips.Text = chips
          End If
      End If
  End Sub
  </code></pre>