none
Simple quick question - How do I indicate when a button has been clicked using a msgbox by saying it has been selected once or twice etc.

    Question

  • Hi I would like to use this in my code example.

     In a nutshell the code below updates the amount of gold stored but if the player selects gold mine then the loot added will be for instance If i made purchases of 2 gold mines then it will always add by 60. 
     Private Sub END_1_Click(sender As Object, e As EventArgs) Handles END_1.Click
            Me.Hide()
            Zero_G1.Text = Zero_G1.Text + 20
            Zero_XP1.Text = Zero_XP1.Text + 20
            MessageBox.Show("My turn's done")
            Player2_Game_Grid.Show()
    
            If Build_1.Text = "Gold Mine" Then
                If Build_1.SelectedItem.item(1) > 2 Then
                    Zero_XP1.Text = Zero_XP1.Text + 40
                ElseIf Build_1.SelectedItem.item(1) > 3 Then
                    Zero_XP1.Text = Zero_XP1.Text + 60
                ElseIf Build_1.SelectedItem.item(1) > 4 Then
                    Zero_XP1.Text = Zero_XP1.Text + 80
                ElseIf Build_1.SelectedItem.item(1) > 5 Then
                    Zero_XP1.Text = Zero_XP1.Text + 100
                End If
            End If
    End Sub 


    WRA

    Saturday, April 22, 2017 3:03 PM

Answers

  • Use a Static variable (instead of Dim) for the number of clicks in the button code.  It will remember the total each time you click on the button.

    Static click As Integer
    click += 1
    'display number of clicks in a message box


    Solitaire

    • Marked as answer by Waliur Rahman Saturday, April 22, 2017 5:03 PM
    Saturday, April 22, 2017 4:06 PM

All replies

  • One error found the areas in the if statement where it says Zero_XP1 it should be zero_g1

    WRA

    Saturday, April 22, 2017 3:25 PM
  • Use a Static variable (instead of Dim) for the number of clicks in the button code.  It will remember the total each time you click on the button.

    Static click As Integer
    click += 1
    'display number of clicks in a message box


    Solitaire

    • Marked as answer by Waliur Rahman Saturday, April 22, 2017 5:03 PM
    Saturday, April 22, 2017 4:06 PM
  • Ill give it a shot 

    WRA

    Saturday, April 22, 2017 4:11 PM
  • Got that part working so each time I have selected it, shows how many times the button has been selected. 

    The next step is indicating when the purchase button has been selected 3 times then loot_g = loot_g + 60 or so.


    WRA

    Saturday, April 22, 2017 4:16 PM
  • Thanks for the help Solitaire :) have a good day

    WRA

    Saturday, April 22, 2017 5:03 PM