Results 1 to 9 of 9

Thread: [RESOLVED] output file (.txt) problem

  1. #1

    Thread Starter
    Lively Member chxxangie's Avatar
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    79

    Resolved [RESOLVED] output file (.txt) problem

    ********************************************************************
    Digital Curemeter Data Acqusition and Display System

    Experimenter.................. qiqi
    Sampling Frequency......... miliseconds
    Start time...................... start_datetime
    End time........................ end_datetime
    Total number of Data....... lbl_listcount.Caption
    Tag Name...................... Text2.Text
    Units............................. Text7.Text
    ********************************************************************

    COLLECTION OF DATA (Analog Input of 8 Channel)

    No CHN 1 CHN 2 CHN 3 CHN 4 CHN 5 CHN 6 CHN 7 CHN 8
    ------------------------------------------------------------------
    1 142 107 116 58 61 155 3 153
    2 163 142 10 83 173 159 75 193
    3 175 12 190 73 105 154 11 119
    4 94 60 125 130 53 56 166 165
    5 118 198 183 46 140 197 49 107
    6 22 200 136 4 116 21 21 160
    7 57 10 60 77 61 190 196 81
    8 56 33 33 130 83 83 143 66
    9 127 42 38 117 17 92 182 53
    10 158 76 58 184 127 126 86 20


    ###################################################
    the top one is the output file.but what the problem is start from line 17 to last line (orange color part) have not been arranged neatly.
    can VB6 make it neatly?
    the value length is not sure.can be integer, can be double also....
    can anybody help me to settle this problem? thanks.....

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: output file (.txt) problem

    How many maximum digits those numbers can have ?

    If you add correct number of spaces after the numbers and display the final file using a fixed-size font (Courier /Lucida Console/ FixedSys), then it will look good.

    PS.
    Welcome to VBForums!
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: output file (.txt) problem

    Format each value to take 3 characters.
    VB Code:
    1. Right$("   " & <your variable>,3)
    (Or as many characters as the maximum you'll be seeing. Just change the code to that many spaces and that number.)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  4. #4

    Thread Starter
    Lively Member chxxangie's Avatar
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    79

    Re: output file (.txt) problem

    to A142:

    why when i insert the code, it will pop up
    "Compile error:"
    "Expected:="

  5. #5
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: output file (.txt) problem

    You can't just throw that code in anywhere. You need to put it in place of your numbers when you would print those numbers to the output file. For example, instead of this:
    VB Code:
    1. Print #1, Number
    use this:
    VB Code:
    1. Print #1, Right$(Space(6) & Number, 6)
    Since you said your number might not be integer, you should probably also use the Format() function to ensure that any decimal points line up in the columns.
    If you need more help, please show us your code that creates this output file, so we can tell you more precisely how to create it in the way that you want.

  6. #6

    Thread Starter
    Lively Member chxxangie's Avatar
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    79

    Re: output file (.txt) problem

    If opt_txt.Value = True Then
    Open show_dir For Append As #1
    Print #1, "********************************************************************"
    Print #1, "Digital Curemeter Data Acqusition and Display System"
    Print #1, ""
    Print #1, "Experimenter..............", user_reg.txt_username
    Print #1, "Sampling Frequency........", TxtRate & " miliseconds"
    Print #1, "Start time................", start_datetime
    Print #1, "End time..................", end_datetime
    Print #1, "Total number of Data......", lbl_listcount.Caption
    Print #1, "Tag Name..................", Text2.Text
    Print #1, "Units.....................", Text7.Text
    Print #1, "********************************************************************"
    Print #1, ""
    Print #1, "COLLECTION OF DATA (Analog Input of 8 Channel)"
    Print #1, ""
    Print #1, "No CHN 1 CHN 2 CHN 3 CHN 4 CHN 5 CHN 6 CHN 7 CHN 8"
    Print #1, "------------------------------------------------------------------"

    For a = 0 To List1(0).ListCount - 1
    txt00 = List1(0).List(a)
    txt01 = List1(1).List(a)
    txt02 = List1(2).List(a)
    txt03 = List1(3).List(a)
    txt04 = List1(4).List(a)
    txt05 = List1(5).List(a)
    txt06 = List1(6).List(a)
    txt07 = List1(7).List(a)

    Print #1, a + 1 & " " & txt00 & " " & txt01 & " " & txt02 & " " & txt03 & " " & txt04 & " " & txt05 & " " & txt06 & " " & txt07
    Next
    Close #1
    End If

  7. #7

    Thread Starter
    Lively Member chxxangie's Avatar
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    79

    Re: output file (.txt) problem

    above is my code......now is the output file........

    ********************************************************************
    Digital Curemeter Data Acqusition and Display System

    Experimenter.............. User
    Sampling Frequency........ 50 miliseconds
    Start time................ 2/14/2007 6:23:16 PM
    End time.................. 2/14/2007 6:23:16 PM
    Total number of Data...... 12
    Tag Name.................. AVAR1
    Units..................... mV
    ********************************************************************

    COLLECTION OF DATA (Analog Input of 8 Channel)

    No CHN 1 CHN 2 CHN 3 CHN 4 CHN 5 CHN 6 CHN 7 CHN 8
    ------------------------------------------------------------------
    1 156 77 117 75 105 95 118 155
    2 32 33 49 36 105 193 79 60
    3 10 189 55 135 200 76 74 92
    4 93 26 40 49 200 4 66 143
    5 96 185 8 153 15 126 138 156
    6 65 14 60 130 33 176 33 88
    7 154 143 42 34 133 197 155 114
    8 140 122 38 192 164 133 14 94
    9 2 107 123 173 63 57 123 74
    10 138 189 155 189 30 61 146 51
    11 38 186 23 159 146 187 92 182
    12 8 70 146 16 48 14 168 41

  8. #8
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: output file (.txt) problem

    I have modified your code:
    VB Code:
    1. If opt_txt.Value Then ' Since opt_txt.Value is Boolean, the "= True" part is redundant
    2.     Open show_dir For Append As #1
    3.         Print #1, "********************************************************************"
    4.         Print #1, "Digital Curemeter Data Acqusition and Display System"
    5.         Print #1, ' Empty string is implied, no need for ""
    6.         Print #1, "Experimenter..............", user_reg.txt_username ' You probably want to use semicolon (;) instead of comma
    7.         Print #1, "Sampling Frequency........", TxtRate & " miliseconds"
    8.         Print #1, "Start time................", start_datetime
    9.         Print #1, "End time..................", end_datetime
    10.         Print #1, "Total number of Data......", lbl_listcount.Caption
    11.         Print #1, "Tag Name..................", Text2.Text
    12.         Print #1, "Units.....................", Text7.Text
    13.         Print #1, "********************************************************************"
    14.         Print #1,
    15.         Print #1, "COLLECTION OF DATA  (Analog Input of 8 Channel)"
    16.         Print #1,
    17.         Print #1, "No   CHN 1   CHN 2   CHN 3   CHN 4   CHN 5   CHN 6   CHN 7   CHN 8"
    18.         Print #1, "------------------------------------------------------------------"
    19.    
    20.         For a = 0 To List1(0).ListCount - 1
    21.             Print #1, Format(a + 1, "00");
    22.             For b = 0 to 7 ' be sure to declare this new variable (declare [i]all[/i] variables)
    23.                 Print #1, Right$(Space(8) & List1(b).List(a), 8); ' 8 should line these up under the CHN numbers
    24.             Next b
    25.             Print #1, ' This moves to the next line in the file, because the Print statement in the loop does not
    26.         Next
    27.     Close #1
    28. End If

    P.S. Please use [vbcode][/vbcode] tags around your code to make it easier to read on the forum pages.

  9. #9

    Thread Starter
    Lively Member chxxangie's Avatar
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    79

    Re: output file (.txt) problem

    thanks for helping.....this forum is very nice.......
    thank you so much....

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