作業中のvb.netプログラムに3つの問題があります。ユーザーがロールをクリックすると、ランダムにロールして、ロールしたサイコロの写真が表示されるダイスゲームを作成しています。プレイしたいチップの数と賭けている数を選択できます。彼らはそれぞれ3つのサイコロを振ります。
ここに問題があります:
重複-ユーザーがロールとランダムに生成された数字をクリックすると、2つは同じで、1つは表示されません。それらの1つを表示する必要があります
画像が画像ボックスに移動する-サイコロの画像を画像ボックスに移動させようとしています。再生したときに物が見えるようにするよりも優れています。
GUIの画像:http://i.imgur.com/Kn6Nd.png
現在のコード:
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