Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Loop does not Display Text for each Iteration 1

Status
Not open for further replies.
Aug 1, 2003
39
US
I want the For Loop to display an answer on each line of the textbox but it never happens. Only the final answer shows up in the text box. What am I doing wrong?

Code:
   Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Dim counter As Integer
        Dim factorial As Long = 1
        For counter As Integer = 1 To 20
            factorial *= counter
            Label1.Text = Convert.ToString(counter) & vbCrLf
            Label2.text = Convert.ToString(factorial) & vbCrLf
        Next
    End Sub
End Class



--------------------------
Thanks
Brian

 
I would use a listbox it's easier

Dim factorial As Long = 1
For counter As Integer = 1 To 20
factorial *= counter
ListBox1.Items.Add(Convert.ToString(counter) & vbTab & convert.ToString(factorial))
Next
 
Try this
Code:
            Label1.Text [blue]&[/blue]= Convert.ToString(counter) & vbCrLf
            Label2.text [blue]&[/blue]= Convert.ToString(factorial) & vbCrLf
 
This works mansii

Thank You

--------------------------
Thanks
Brian

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top