sum numbers

hello there,
I have this code and I would like to see the numbers increasing in the textbox from 0 to 1000 but it doesn't show that..
I only see 0 then when I click It takes a few seconds then I see 1000.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        While (txtPublic.Text < 10000)
            txtPublic.Text = txtPublic.Text + 1
        End While
    End Sub

Open in new window

LVL 1
XK8ERAsked:
Who is Participating?
 
SameerJagdaleConnect With a Mentor Commented:
just add            
Application.DoEvents() after the line:
txtPublic.Text = txtPublic.Text + 1

 
0
 
BinuthCommented:
try this
 While (CInt(txtPublic.Text) < 10000)
            txtPublic.Text = CInt(txtPublic.Text) + 1
            System.Threading.Thread.Sleep(50)
            Application.DoEvents()
 End While

Open in new window

0
 
SameerJagdaleCommented:
you have to use timer component if you want to update UI.
0
 
kaylanreilorCommented:
Add txtPublic.Refresh() into the while loop after calculation.
0
 
kaylanreilorCommented:
But you don't need to process ALL the pending events in the WHOLE application at this stage ! You only need to refresh the targetted window.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.