Solved

sum numbers

Posted on 2008-09-29
5
180 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

Industry Leaders: 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 When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

718 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