Solved

sum numbers

Posted on 2008-09-29
5
174 Views
Last Modified: 2010-04-23
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

0
Comment
Question by:XK8ER
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:Binuth
ID: 22603015
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
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22603029
you have to use timer component if you want to update UI.
0
 
LVL 13

Expert Comment

by:kaylanreilor
ID: 22603036
Add txtPublic.Refresh() into the while loop after calculation.
0
 
LVL 13

Accepted Solution

by:
SameerJagdale earned 500 total points
ID: 22603039
just add            
Application.DoEvents() after the line:
txtPublic.Text = txtPublic.Text + 1

 
0
 
LVL 13

Expert Comment

by:kaylanreilor
ID: 22603114
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now