|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
List Box PopulationVB 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
Show quote
Hide quote
"Paul Anderson" <pate***@magma.ca> wrote in message Listbox, or textbox?news:MK2dnUQkJLu6CAzZnZ2dnUVZ_t-dnZ2d@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 > 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 wrote:
Show quoteHide quote > "Paul Anderson" <pate***@magma.ca> wrote in message Thanks for the response but it's a textbox so items.add won't work.> news:MK2dnUQkJLu6CAzZnZ2dnUVZ_t-dnZ2d@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, The output is produced, but only after the procedure has completed. I'd like it to refresh while looping through the procedure. Paul Paul Anderson wrote:
> like it to refresh while looping through the procedure. Try addingt TextBox1.Refresh to the loopChris Dunaway wrote:
> Paul Anderson wrote: Thank you. Just what I needed.> >> like it to refresh while looping through the procedure. > > Try addingt TextBox1.Refresh to the loop > Chris, Paul. Your code should be:
TextBox1.Text = TextBox1.Text & "Loop " & i & wrap Me.Refresh() System.Threading.Thread.Sleep(1000) -- Show quoteHide quoteTerry "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 >
How to Send an SMS
URI IsFile Streaming a file to text? How to force upper case in a DataGridView column? VB.net 2005 splash screen How to get Windows XP Edition? "Optional ByVal SomeDate As Date = Nothing" in VB2005 Count Rcords Updating a DataSet while using DataGridView writing a text in a file in vb.net not working properly |
|||||||||||||||||||||||