Results 1 to 6 of 6

Thread: [RESOLVED] Updating Labels text within a "for loop" sequentially?

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Location
    Charlotte, NC - USA
    Posts
    3

    Resolved [RESOLVED] Updating Labels text within a "for loop" sequentially?

    Embarassingly enough, I posted in the wrong forum the first time around, and I'm pretty sure that's why it never even appeared. Oh well. THIS is the right forum now, I hope, so here's my problem:

    I'm basically simulating bowling. I've created a form that has a "scoreboard" on it, and I'm updating the cells of the scoreboard to display the bowl result. Without doing 21 if statements, I figured I could call a method, send it which roll number it is, and then use a for loop to update each label's text values.

    So, here's what I have:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Code:
            Dim counterRolls, tempRoll, counterTotal As Integer
            counterTotal = 1
            For counterRolls = 1 To 20
                If counterRolls Mod 2 = 1 Then
                    tempRoll = rollGame(counterRolls)
                    If tempRoll = 10 Then
                        counterRolls += 1
                    End If
                Else
                    tempRoll = rollGame(counterRolls, tempRoll)
                End If
                If roll19.Text = "10" And roll20.Text = "10" Then
                    tempRoll = rollGame(21)
                Else
                    roll21.Text = "Null"
                End If
            Next
        End Sub
    That is the button click function that calls one of two methods depending on the variables. For example, one method is here:

    Code:
        Private Overloads Function rollGame(ByVal rollNum As Integer) As Integer
            randomNum = randomGenerator.Next(0, 11)
            Select Case rollNum
                Case Is = 11
                    MessageBox.Show("Congratulations!  That's a STRIKE!")
                Case Is < 11
                    MessageBox.Show("You knocked down " + randomNum + "pins!")
            End Select
            roll(rollNum).Text(randomNum.ToString)
    
        End Function
    Clearly, this part "roll(rollNum).Text(randomNum.ToString)" is the part that I tried and failed to update the label. The labels are labelled, in this case, roll1 through roll21.

    Is there anything I can do to resolve this problem?

    Thanks so much!

    -William
    Last edited by Pansophist; Apr 20th, 2009 at 03:31 AM.

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