473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

List Box Population

I have a newbie question that I hope someone can answer.
VB Studio 2005

I have a form with a button and a listbox. When the button is pressed
the following routine is run:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim wrap As String
wrap = Chr(13) & Chr(10)
For i = 1 To 10
TextBox1.Text = TextBox1.Text & "Loop " & i & wrap
System.Threading.Thread.Sleep(1000)
Next i
End Sub
End Class

All this does is populate the listbox with loop1,loop2, etc with a crlf
at the end of each loopx.

While this is running I can see that the listbox is getting bigger
because the elevator bar is created and successively gets smaller as
more loops are run. However the words ("loopx") do not appear in the
listbox until the entire 10 iterations of the loop are complete.

Can anyone tell me why this happens? Is there a cure? Can I make it so
that each "loopx" line appears successively once per second in the box?

Thank you.

Paul Anderson
Jun 15 '06 #1
5 1359

"Paul Anderson" <pa*****@magma.ca> wrote in message
news:MK******************************@magma.ca...
I have a newbie question that I hope someone can answer.
VB Studio 2005

I have a form with a button and a listbox. When the button is pressed
the following routine is run:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim wrap As String
wrap = Chr(13) & Chr(10)
For i = 1 To 10
TextBox1.Text = TextBox1.Text & "Loop " & i & wrap
System.Threading.Thread.Sleep(1000)
Next i
End Sub
End Class


Listbox, or textbox?

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button3.Click

Dim i As Integer

For i = 0 To 10

ListBox1.Items.Add("text " + CStr(i))

Next i

End Sub

cheers

Henry
Jun 15 '06 #2
Henry wrote:
"Paul Anderson" <pa*****@magma.ca> wrote in message
news:MK******************************@magma.ca...
I have a newbie question that I hope someone can answer.
VB Studio 2005

I have a form with a button and a listbox. When the button is pressed
the following routine is run:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim wrap As String
wrap = Chr(13) & Chr(10)
For i = 1 To 10
TextBox1.Text = TextBox1.Text & "Loop " & i & wrap
System.Threading.Thread.Sleep(1000)
Next i
End Sub
End Class


Listbox, or textbox?

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button3.Click

Dim i As Integer

For i = 0 To 10

ListBox1.Items.Add("text " + CStr(i))

Next i

End Sub

cheers

Henry

Henry,
Thanks for the response but it's a textbox so items.add won't work.
The output is produced, but only after the procedure has completed. I'd
like it to refresh while looping through the procedure.
Paul
Jun 15 '06 #3
Paul Anderson wrote:
like it to refresh while looping through the procedure.


Try addingt TextBox1.Refresh to the loop

Jun 15 '06 #4
Your code should be:
TextBox1.Text = TextBox1.Text & "Loop " & i & wrap
Me.Refresh()
System.Threading.Thread.Sleep(1000)

--
Terry
"Paul Anderson" wrote:
I have a newbie question that I hope someone can answer.
VB Studio 2005

I have a form with a button and a listbox. When the button is pressed
the following routine is run:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim wrap As String
wrap = Chr(13) & Chr(10)
For i = 1 To 10
TextBox1.Text = TextBox1.Text & "Loop " & i & wrap
System.Threading.Thread.Sleep(1000)
Next i
End Sub
End Class

All this does is populate the listbox with loop1,loop2, etc with a crlf
at the end of each loopx.

While this is running I can see that the listbox is getting bigger
because the elevator bar is created and successively gets smaller as
more loops are run. However the words ("loopx") do not appear in the
listbox until the entire 10 iterations of the loop are complete.

Can anyone tell me why this happens? Is there a cure? Can I make it so
that each "loopx" line appears successively once per second in the box?

Thank you.

Paul Anderson

Jun 15 '06 #5
Chris Dunaway wrote:
Paul Anderson wrote:
like it to refresh while looping through the procedure.


Try addingt TextBox1.Refresh to the loop

Chris,
Thank you. Just what I needed.
Paul.
Jun 15 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bart Nessux | last post by:
New to Python... trying to figure out how to count the objects in a list and then map the count to the objects or convert the list to a dict... I think the latter would be better as I need a number...
6
by: Bart Nessux | last post by:
number = random.sample(range(count), 1) This makes 'number' into a one entry list (I don't know why as 'count' is an integer). Is there an easy way to convert 'number' back to an int? TIA
0
by: Megan | last post by:
Data Comparison: Sample Versus Rest of Population. I have a population of data, and I want to take a sample of that population and compare it against the entire population. I have a database...
7
by: David Freeman | last post by:
Hi There! I'm trying to create a User Registration page in ASP.NET and wondering what is the best way to get the list of up-to-date Countries and Cities? Are there any Web Services on the web...
1
by: Arun | last post by:
Hi Group, I was trying to link a combo box with a list control and having some trouble with that. Could anyone please help me with that. Here's the example of the scenario. Combo Box ;-...
0
by: Paul Hadfield | last post by:
I'm looking for thoughts on the "correct" design for this problem (DotNet 2.0 - in winforms, but that's not so important). I've got two combo boxes (combo1 and combo2), both are populating via...
14
by: neonman14 | last post by:
Hello I am in Intro to Java Programming and I am having problems with assignment. The Homework assignment is called Population. Population Write a program that will predict the size of a...
12
by: Chris | last post by:
Are there any other controls which could replace List & Tree controls, because they have limitation of accepting only 32767 items. thanks a lot in advance.
1
by: Clive Swan | last post by:
Hi I am trying to sum a population field that may have 140 records for each Ward (example). Any suggestions on the best way to do this. I would like to have a unique record for each Ward...
1
by: tg | last post by:
http://img522.imageshack.us/img522/8647/scan10005ci7.jpg As a percentage of world inhabitants, the white population will plummet to a single digit (9.76%) by 2060 from a high-water mark of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.