Results 1 to 13 of 13

Thread: Write Multiple Label.Text's to *.txt Files

  1. #1

    Thread Starter
    Lively Member SLeePYG72786's Avatar
    Join Date
    Sep 2010
    Posts
    66

    Question Write Multiple Label.Text's to *.txt Files

    I'm trying to implement Bandwidth Total calculation into my little desktop monitoring program using 2 *.txt files. Everything else is working great except for the writing/reading part of it. I had put this together originally without the intention of bandwidth monitoring, but I've decided it would be a good thing to have.

    I want to have 2 monitoring types: Windows Session Bandwidth Total & All-Time Bandwidth Total (since the program was 1st run on the machine). The counter is on a Timer (2nd of 2), and I want it to write and add the label values each second into the file, then when Form3 is opened, to read the text file and show the results.

    The folder that contains the solution is 1.82MB (larger than max attachment size for this forum), so I uploaded it to Mediafire.

    Any and all help is very much appreciated. Thanks in advance.

    (.zip format)
    http://www.mediafire.com/?j178sqd7e0kdrit

    EDIT > Removed all .exe's and reuploaded
    Last edited by SLeePYG72786; Feb 10th, 2012 at 01:00 PM.

  2. #2

    Thread Starter
    Lively Member SLeePYG72786's Avatar
    Join Date
    Sep 2010
    Posts
    66

    Re: Write Multiple Label.Text's to *.txt Files

    Bump please.

  3. #3

    Thread Starter
    Lively Member SLeePYG72786's Avatar
    Join Date
    Sep 2010
    Posts
    66

    Re: Write Multiple Label.Text's to *.txt Files

    Anybody?

  4. #4
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    351

    Re: Write Multiple Label.Text's to *.txt Files

    So you're just after a way to write to and then read from a text file?

    If so:
    http://www.techrepublic.com/article/...ic-net/1045309

    You may want to look at the My.settings. feature of VS, it provides a very easy way to save settings and values between project sessions.
    Rico

    Using: VB.net & MS SQL

  5. #5

    Thread Starter
    Lively Member SLeePYG72786's Avatar
    Join Date
    Sep 2010
    Posts
    66

    Re: Write Multiple Label.Text's to *.txt Files

    I'm not sure how I could use the My.Settings feature for this program. I'm aware of what it does and how to use it, but I don't think it could work in this case. Did you check the solution I uploaded?

    EDIT > Thanks for the reply.

  6. #6
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    351

    Re: Write Multiple Label.Text's to *.txt Files

    I would see my.settings working like so:

    Say you have SessionUsage as a local variable, which you add to when the app is running. When the app is closing, you do My.settings.TotalUsage += SessionUsage and similar other variables.

    Sorry this a bit of a diversion, and you are correct may not be right for your app. Just a suggestion.

    I have not been through your app. I would think most would not, if you have a particular issue with a bit of code, post that. Not many here will go through, then fix, an entire solution for you.
    Rico

    Using: VB.net & MS SQL

  7. #7

    Thread Starter
    Lively Member SLeePYG72786's Avatar
    Join Date
    Sep 2010
    Posts
    66

    Re: Write Multiple Label.Text's to *.txt Files

    Oh lord, I don't expect anybody to fix anything or go through the whole thing, just the relevant part I need help with (Form1 code, actually).

    Now I see how I might be able to use My.Settings for this, but how could I apply that to be used with Form3? (which I want to be able to use to see Totals in real-time)

    Thanks again for your replies. =)

  8. #8
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    351

    Re: Write Multiple Label.Text's to *.txt Files

    When form3 is loaded, I assume it has some labels on to display your values, you could do the following:

    label1.text = "Usage this session: " & SessionUsage
    label2.text = "Total usage: " & My.settings.TotalUsage + Session Usage

    (P.S. Is good practice to name your forms and labels etc a sensible name that relates to their usage. A requirement when projects get larger. Search for vb.net naming conventions.)
    Rico

    Using: VB.net & MS SQL

  9. #9

    Thread Starter
    Lively Member SLeePYG72786's Avatar
    Join Date
    Sep 2010
    Posts
    66

    Re: Write Multiple Label.Text's to *.txt Files

    Thanks for helping me out. I truly appreciate it.

    Most of the time my projects aren't large enough to need to rename my Forms; however I always use unique names for the controls on them. =)

  10. #10
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    351

    Re: Write Multiple Label.Text's to *.txt Files

    No prob, if you've got enough to move on, please mark the thread RESOLVED
    Rico

    Using: VB.net & MS SQL

  11. #11

    Thread Starter
    Lively Member SLeePYG72786's Avatar
    Join Date
    Sep 2010
    Posts
    66

    Re: Write Multiple Label.Text's to *.txt Files

    I will after I get time to try it out.

  12. #12
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Write Multiple Label.Text's to *.txt Files

    Hello SLeePYG72786, The main reason for lake of reply's is because you have just asked your question and attached your project. Now why should we go through the hassle of downloading your project. Unzipping it. Checking for EXE files, which at this point i would like to point out to you that this is against forum rules attaching files that contain executable's so may be advised to remove it, and then searching your project for the part that needs editing or what ever.

    So you need to save your labels text value and pass it to form3. So why are you needing to save this to a text file? Or My.settings which would not suite here any way. Unless you need to recall the settings when the project reloads.

    Why not pass the values in the forms constructor?

    Off topic i would take a deeper look into your project there are many bad examples.

    for example

    Code:
    If chkShowInTaskbar.CheckState = CheckState.Checked Then
       Form1.ShowInTaskbar = True
    Else
        Form1.ShowInTaskbar = False
    End If
    If you was to use this example it should be

    Code:
    If chkShowInTaskbar.Checked Then
       Form1.ShowInTaskbar = True
    Else
        Form1.ShowInTaskbar = False
    End If
    Finally

    Code:
    Form1.ShowInTaskbar = Me.chkShowInTaskbar.Checked
    Last edited by ident; Feb 10th, 2012 at 12:27 PM.

  13. #13

    Thread Starter
    Lively Member SLeePYG72786's Avatar
    Join Date
    Sep 2010
    Posts
    66

    Re: Write Multiple Label.Text's to *.txt Files

    Removed all .exe's and reuploaded.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width