473,802 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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.Threadin g.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 1374

"Paul Anderson" <pa*****@magma. ca> wrote in message
news:MK******** *************** *******@magma.c a...
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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.Threadin g.Thread.Sleep( 1000)
Next i
End Sub
End Class


Listbox, or textbox?

Protected Sub Button3_Click(B yVal sender As Object, ByVal e As
System.EventArg s) 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.c a...
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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.Threadin g.Thread.Sleep( 1000)
Next i
End Sub
End Class


Listbox, or textbox?

Protected Sub Button3_Click(B yVal sender As Object, ByVal e As
System.EventArg s) 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.Refres h to the loop

Jun 15 '06 #4
Your code should be:
TextBox1.Text = TextBox1.Text & "Loop " & i & wrap
Me.Refresh()
System.Threadin g.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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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.Threadin g.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.Refres h 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
2964
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 associated with each entry. Any pointers? Also, does this bit of code look to be truely random? def random_number_gen(): winner = winner.append(random.sample(xrange(100000), 1))
6
2095
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
3742
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 that records information about the types of Rulings a person receives. Each person works for an agency, and there are 12 agencies (see example below). Each person receives a ruling, and there are 2 types of rulings,
7
3807
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 that I can use to retrieve such information? If not, what are the options? Please, any suggestions and pointers will be very much appreciated! Dave
1
2017
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 ;- Country_Names (Pulls values from the country table(Just the country_name value)) (Each country will have a table by itself, For Example USA will be a
0
3699
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 database calls (using a separate DB handler class). "combo1" contains a list of countries and is fairly static, it can be added to but no other external events cause a change in its population. "combo2" however is populated with a list of options...
14
16849
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 population of organisms. The program should ask for the starting number of organisms, their average daily population increase (as a percentage), and the number of days they will multiply. For example, a population might begin with two organisms, have an...
12
2335
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
2017
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 with all the records summed.
1
4673
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 27.98% in 1950. The big population story of the 21st Century is shaping up to be the status reversal of whites and blacks and the Indian baby boom. A side bar will be the single digit minority role that whites will assume. Of the 7 population groups...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.