Solved

sum numbers

Posted on 2008-09-29
5
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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