View Data in Textbox

Discussion in 'Microsoft VB .NET' started by John Smith, Dec 8, 2004.

  1. John Smith

    John Smith Guest

    I have a form doing a large process. While this form is doing its
    processing I want to write a status to a Textbox of where it is at in the
    process. Similar to having a log file but within a textbox. As it reaches
    its mark it adds a line to the textbox "Step 2 is complete." or "Step 3
    Failed because of...". My problem is that the text within the textbox does
    not display until after all of the processing is complete. How can I get
    the text to display when it reaches each specific process? Thanx in advance
     
    John Smith, Dec 8, 2004
    #1
    1. Advertisements

  2. Two ways. one and simple way is to use Application.DoEvents() after you
    update the text box but a lot of people say to avoid using that function.
    The more complicated way is to use threading to do the processing in a
    seperate thread from the UI.

    Chris


    "John Smith" <> wrote in message
    news:uzL%...
    >I have a form doing a large process. While this form is doing its
    > processing I want to write a status to a Textbox of where it is at in the
    > process. Similar to having a log file but within a textbox. As it
    > reaches
    > its mark it adds a line to the textbox "Step 2 is complete." or "Step 3
    > Failed because of...". My problem is that the text within the textbox
    > does
    > not display until after all of the processing is complete. How can I get
    > the text to display when it reaches each specific process? Thanx in
    > advance
    >
    >
     
    Chris, Master of All Things Insignificant, Dec 8, 2004
    #2
    1. Advertisements

  3. John Smith

    Cor Ligthert Guest

    John,

    You mean something as this
    \\\
    Private Sub Form1_Activated(ByVal sender _
    As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
    For i As Integer = 1 To 100000000
    If i Mod 100 = 0 Then
    TextBox1.Show()
    End If
    TextBox1.AppendText(i.ToString)
    Next
    End Sub
    ///

    I hope this helps?

    Cor
     
    Cor Ligthert, Dec 8, 2004
    #3
  4. "John Smith" <> schrieb:
    >I have a form doing a large process. While this form is doing its
    > processing I want to write a status to a Textbox of where it is at in the
    > process. Similar to having a log file but within a textbox. As it
    > reaches
    > its mark it adds a line to the textbox "Step 2 is complete." or "Step 3
    > Failed because of...". My problem is that the text within the textbox
    > does
    > not display until after all of the processing is complete. How can I get
    > the text to display when it reaches each specific process?


    Solution 1:

    \\\
    With Me.Label1
    .Text = ...
    .Refresh()
    End With
    Application.DoEvents() ' See documentation.
    ///

    Solution 2:

    Multithreading + Windows Forms:

    <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.asp>
    <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.asp>
    <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.asp>

    <URL:http://www.devx.com/dotnet/Article/11358/>

    <URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsControlClassInvokeTopic.asp>

    Multithreading in Visual Basic .NET (Visual Basic Language Concepts)
    <URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconthreadinginvisualbasic.asp>

    Sample:

    FileSystemEnumerator
    <URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
     
    Herfried K. Wagner [MVP], Dec 8, 2004
    #4
  5. Herfried, maybe your example here can get you to answer a question I've
    wondered about for a while.

    With Me.Label1
    .Text = ...
    .Refresh()
    End With

    The idea behind the With clause is it allows for faster execution since the
    "Me" ojbect doesn't have to be resolved 2 times in your example. But you
    could rewrite your sample w/o the Me

    With Label1
    .Text = ...
    .Refresh()
    End With

    In this case there wouldn't be any inhancement since you are not actually
    eliminating the dot. Am I correct in my thinking?

    Chris


    "Herfried K. Wagner [MVP]" <> wrote in message
    news:...
    > "John Smith" <> schrieb:
    >>I have a form doing a large process. While this form is doing its
    >> processing I want to write a status to a Textbox of where it is at in the
    >> process. Similar to having a log file but within a textbox. As it
    >> reaches
    >> its mark it adds a line to the textbox "Step 2 is complete." or "Step 3
    >> Failed because of...". My problem is that the text within the textbox
    >> does
    >> not display until after all of the processing is complete. How can I get
    >> the text to display when it reaches each specific process?

    >
    > Solution 1:
    >
    > \\\
    > With Me.Label1
    > .Text = ...
    > .Refresh()
    > End With
    > Application.DoEvents() ' See documentation.
    > ///
    >
    > Solution 2:
    >
    > Multithreading + Windows Forms:
    >
    > <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.asp>
    > <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.asp>
    > <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.asp>
    >
    > <URL:http://www.devx.com/dotnet/Article/11358/>
    >
    > <URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsControlClassInvokeTopic.asp>
    >
    > Multithreading in Visual Basic .NET (Visual Basic Language Concepts)
    > <URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconthreadinginvisualbasic.asp>
    >
    > Sample:
    >
    > FileSystemEnumerator
    > <URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>
    >
    > --
    > M S Herfried K. Wagner
    > M V P <URL:http://dotnet.mvps.org/>
    > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
     
    Chris, Master of All Things Insignificant, Dec 8, 2004
    #5
  6. Chris,

    "Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com>
    schrieb:
    > Herfried, maybe your example here can get you to answer a question I've
    > wondered about for a while.
    >
    > With Me.Label1
    > .Text = ...
    > .Refresh()
    > End With
    >
    > The idea behind the With clause is it allows for faster execution since
    > the "Me" ojbect doesn't have to be resolved 2 times in your example. But
    > you could rewrite your sample w/o the Me
    >
    > With Label1
    > .Text = ...
    > .Refresh()
    > End With
    >
    > In this case there wouldn't be any inhancement since you are not actually
    > eliminating the dot. Am I correct in my thinking?


    The 'Me.' is resolved even if it's not explicitly written. In this case I
    used With type the code faster ;-).

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
     
    Herfried K. Wagner [MVP], Dec 9, 2004
    #6
  7. John Smith

    Cor Ligthert Guest

    Chis,

    Not true,

    The "Me" is only for the programmer, it does nothing at runtime.

    The With clause creates an extra reference in a program. In this case it
    will be slower than a program without a With clause, however think than
    probably in parts of nanoseconds.

    I hope this gives some ideas?

    Cor


    "Chris, Master of All Things Insignificant"
    ..
    > Herfried, maybe your example here can get you to answer a question I've
    > wondered about for a while.
    >
    > With Me.Label1
    > .Text = ...
    > .Refresh()
    > End With
    >
    > The idea behind the With clause is it allows for faster execution since
    > the "Me" ojbect doesn't have to be resolved 2 times in your example. But
    > you could rewrite your sample w/o the Me
    >
    > With Label1
    > .Text = ...
    > .Refresh()
    > End With
    >
    > In this case there wouldn't be any inhancement since you are not actually
    > eliminating the dot. Am I correct in my thinking?
    >
    > Chris
    >
    >
    > "Herfried K. Wagner [MVP]" <> wrote in message
    > news:...
    >> "John Smith" <> schrieb:
    >>>I have a form doing a large process. While this form is doing its
    >>> processing I want to write a status to a Textbox of where it is at in
    >>> the
    >>> process. Similar to having a log file but within a textbox. As it
    >>> reaches
    >>> its mark it adds a line to the textbox "Step 2 is complete." or "Step 3
    >>> Failed because of...". My problem is that the text within the textbox
    >>> does
    >>> not display until after all of the processing is complete. How can I
    >>> get
    >>> the text to display when it reaches each specific process?

    >>
    >> Solution 1:
    >>
    >> \\\
    >> With Me.Label1
    >> .Text = ...
    >> .Refresh()
    >> End With
    >> Application.DoEvents() ' See documentation.
    >> ///
    >>
    >> Solution 2:
    >>
    >> Multithreading + Windows Forms:
    >>
    >> <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.asp>
    >> <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.asp>
    >> <URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.asp>
    >>
    >> <URL:http://www.devx.com/dotnet/Article/11358/>
    >>
    >> <URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsControlClassInvokeTopic.asp>
    >>
    >> Multithreading in Visual Basic .NET (Visual Basic Language Concepts)
    >> <URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconthreadinginvisualbasic.asp>
    >>
    >> Sample:
    >>
    >> FileSystemEnumerator
    >> <URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>
    >>
    >> --
    >> M S Herfried K. Wagner
    >> M V P <URL:http://dotnet.mvps.org/>
    >> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    >
    >
     
    Cor Ligthert, Dec 9, 2004
    #7
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charms Zhou

    how to update or add data using TextBox

    Charms Zhou, Sep 28, 2003, in forum: Microsoft VB .NET
    Replies:
    3
    Views:
    290
    Armin Zingler
    Sep 29, 2003
  2. alan

    Data Binding with listview and textbox

    alan, Oct 22, 2003, in forum: Microsoft VB .NET
    Replies:
    3
    Views:
    926
    Armin Zingler
    Oct 23, 2003
  3. Parthiv Joshi
    Replies:
    2
    Views:
    1,171
    parthiv joshi
    Jul 7, 2004
  4. Daren Hawes
    Replies:
    2
    Views:
    658
    Cor Ligthert
    Jul 27, 2004
  5. Luqman
    Replies:
    2
    Views:
    1,232
    Luqman
    Jan 2, 2006
  6. Pieter
    Replies:
    1
    Views:
    328
  7. Rob W
    Replies:
    0
    Views:
    485
    Rob W
    Mar 6, 2009
  8. Derrick Candler

    TextBox to Array, Array Displayed in Textbox

    Derrick Candler, Sep 25, 2011, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    777
    Derrick Candler
    Sep 25, 2011
Loading...