what's wrong with the codes?

vb.net , help , me Singapore, Singapore
  • 12 years ago
    Enter VB.NET codes for the 'Play' button. The programming codes will do the following steps: a) Generate a 3 random numbers between 1,9 and display on the label controls on the screen. i. Define a random object r. ii. Define 3 integer variables and each to store a generated random number; ie. r.Next(1,9).Display the random number on the screen label controls. b) Deduct cost to bet, $10 per day. Also, increment the number of bet counter every time the button is clicked. i. Define a double variable. Assign this variable with the balance value shown on the screen. ii. Deduct 10 from the variable as cost to bet. iii. Display the new balance value on the screen. iv. In the same logic, add 1 to the bet counter. c) Check to see if user wins. Add 20 to balance, if 2 of the 3 numbers are the same; or Add 100 to balance if all 3 numbers are the same. i. Define a integer variable to calculate winning points. Initialise variable to 0. Compare each of the 3 combination numbers. If 2 numbers are the same, add 1 to the point variable. ii. Finally, if variable is 1, add 20 to balance; if variable is 3, add 100 to balance. d) Stop the game when not enough money to play. i.Check balance value. If balance is below 10, disable the Play button (Hint: check the button property list to find the name of the property associated with enabling and disabling; set the property by using VB.NET codes). ------------------------------ Partial Class _Default Inherits System.Web.UI.Page Public balance As Integer Protected Sub bn_increase_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bn_increase.Click Dim c As Integer c = Convert.ToInt32(lb_count.Text) c = c + 1 lb_count.Text = Convert.ToString(c) 'Dim balance As Integer Dim r As Random = New Random Dim RandomNumber1, RandomNumber2, RandomNumber3 As Integer Dim TotalMoney As Double = 100 Dim win_count As Integer = 0 Dim comb_num As Integer = 0 comb_num = RandomNumber1 comb_num = RandomNumber2 comb_num = RandomNumber3 'lb_balance.Text = balance 'balance = 100 'balance = Convert.ToInt32("lb_balance.text") RandomNumber1 = r.Next(1, 9) RandomNumber2 = r.Next(1, 9) RandomNumber3 = r.Next(1, 9) Label1.Text = RandomNumber1 Label2.Text = RandomNumber2 Label3.Text = RandomNumber3 'If RandomNumber1 <> RandomNumber2 <> RandomNumber3 Then ' comb_num = 0 'lb_balance.Text = balance - 10 'ElseIf RandomNumber1 = RandomNumber2 Then ' comb_num = 2 'ElseIf RandomNumber1 = RandomNumber3 Then ' comb_num = 2 'ElseIf RandomNumber2 = RandomNumber3 Then ' comb_num = 2 'ElseIf RandomNumber1 = RandomNumber2 = RandomNumber3 Then ' comb_num = 3 While balance > 0 If RandomNumber1 = RandomNumber2 Or RandomNumber1 = RandomNumber3 Or RandomNumber2 = RandomNumber3 Then 'balance = 100 + 20 'lb_balance.Text = balance lb_balance.Text = balance + 20 'comb_num = 2 ElseIf RandomNumber1 = RandomNumber2 = RandomNumber3 Then lb_balance.Text = balance + 100 Else 'RandomNumber1 <> RandomNumber2 <> RandomNumber3 Then lb_balance.Text = balance - 10 End If End While 'comb_num = 3 'comb_num = comb_num + (RandomNumber1 <> RandomNumber2) 'comb_num = comb_num + (RandomNumber1 <> RandomNumber3) 'comb_num = comb_num + (RandomNumber2 <> RandomNumber3) 'comb_num = comb_num - (comb_num = 1) 'Select Case comb_num ' Case Is = 0 ' lb_balance.Text = balance - 10 ' Case Is = 2 ' lb_balance.Text = balance + 20 ' Case Is = 3 ' lb_balance.Text = balance + 100 'End Select 'If comb_num = 0 Then ' lb_balance.Text = balance - 10 'End If 'If comb_num = 1 Then ' lb_balance.Text = balance + 20 'End If 'If comb_num = 2 Then ' lb_balance.Text = balance + 20 'End If 'If comb_num = 3 Then ' lb_balance.Text = balance + 100 'End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'balance = 100 'lb_balance.Text = balance End Sub End Class ----------------- what's wrong with the above codes? the calculation part doesnt work well... please help thanks

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.” - Jamie Zawinski