I'm working on my poker clock again now that I found the source, and I need some help with loops. I have a label that has the round number on it, and labels for the small and large blinds for the current round, and for the next round.

I have if statements that work, but I want to use a loop instead, so the blinds can be customized, instead of fixed numbers.

Here's part of the if statement i have that works:

If tempckL = 1 Then
                sBBox.Text = arrSB(tempckL - 1)
                lBBox.Text = arrLB(tempckL - 1)
                nSBBox.Text = arrSB(tempckL)
                nLBBox.Text = arrLB(tempckL)
            ElseIf tempckL = 2 Then
                sBBox.Text = arrSB(tempckL - 1)
                lBBox.Text = arrLB(tempckL - 1)
                nSBBox.Text = arrSB(tempckL)
                nLBBox.Text = arrLB(tempckL)
            ElseIf tempckL = 3 Then
                sBBox.Text = arrSB(tempckL - 1)
                lBBox.Text = arrLB(tempckL - 1)
                nSBBox.Text = arrSB(tempckL)
                nLBBox.Text = arrLB(tempckL)
            End If

tempckL is the label for the round, sBBox is the label for current small blind, lBBox is the label for the current large blind, nSBBox is the label for the next round's small blind, and nLBBox is the label for next round's large blind, arrSB is the array for the small blind values, and arrLB is the array for the large blind values.

What I need is a loop that checks the current round and displays the correct blind values for the current round, and for the next round without using 20 if statements. Any help is appreciated, thanks. I'm not sure if I should use a for loop, a do loop, or a while loop.

From what I can see of your IF statement is that no matter what tempckL is, you always set your labels to the same thing.
So what do you need either IF statements or loops for?

Although, perhaps you should consider a small IF statement.

If tempckL > 0 Then
   sBBox.Text = arrSB(tempckL - 1)
   lBBox.Text = arrLB(tempckL - 1)
   nSBBox.Text = arrSB(tempckL)
   nLBBox.Text = arrLB(tempckL)
Else
   sBBox.Text = ""
   lBBox.Text = ""
   nSBBox.Text = ""
   nLBBox.Text = ""
End If

As I said earlier, it's an array, so the values in the labels are NOT the same thing. When tempckL = 1, then value of the labels for small and large blinds of the current round are the value in the zero position of the array, and the value of the labels of the next round's small and large blinds are the value in the 1 position of the array.

When tempckL = 2, then value of the labels for small and large blinds of the current round are the value in the 1 position of the array, and the value of the labels of the next round's small and large blinds are the value in the 2 position of the array.

When tempckL = 3, then value of the labels for small and large blinds of the current round are the value in the 2 position of the array, and the value of the labels of the next round's small and large blinds are the value in the 3 position of the array.

Understand?

Yes, I understand. Perhaps I formulated myself a bit unclear.

Based on what I can see in the code-snippet you provided is that no matter what value tempckL has (1, 2 or 3), that is the position in the array you will select a value from.

That said, there is really no need for a large IF...ELSE IF-statement to check for every possible value tempckL can have, because it's redundant.

As long as tempckL is either 1, 2 or 3 (or greater?) then all you need to do is assign the values in the array to your labels. Hence my smaller IF statement.

Take a closer look at your IF statement and tell me if I'm wrong.

Since I don't know how the rest of the code looks like and a loop really is called for, then perhaps something like this:

'Loop the rounds 1 through 3
For i As Integer = 1 To 3
   sBBox.Text = arrSB(i - 1)
   lBBox.Text = arrLB(i - 1)
   nSBBox.Text = arrSB(i)
   nLBBox.Text = arrLB(i)
Next

This will put different values in the labels at a very quick rate.

Already solved it myself, but thanks. Yes, I was a little unclear myself too, sorry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.