[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.....
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! :wave:
Re: output file (.txt) problem
Format each value to take 3 characters.
VB Code:
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.)
Re: output file (.txt) problem
to A142:
why when i insert the code, it will pop up
"Compile error:"
"Expected:="
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: use this:
VB Code:
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.
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
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
Re: output file (.txt) problem
I have modified your code:
VB Code:
If opt_txt.Value Then ' Since opt_txt.Value is Boolean, the "= True" part is redundant
Open show_dir For Append As #1
Print #1, "********************************************************************"
Print #1, "Digital Curemeter Data Acqusition and Display System"
Print #1, ' Empty string is implied, no need for ""
Print #1, "Experimenter..............", user_reg.txt_username ' You probably want to use semicolon (;) instead of comma
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
Print #1, Format(a + 1, "00");
For b = 0 to 7 ' be sure to declare this new variable (declare [i]all[/i] variables)
Print #1, Right$(Space(8) & List1(b).List(a), 8); ' 8 should line these up under the CHN numbers
Next b
Print #1, ' This moves to the next line in the file, because the Print statement in the loop does not
Next
Close #1
End If
P.S. Please use [vbcode][/vbcode] tags around your code to make it easier to read on the forum pages.
Re: output file (.txt) problem
thanks for helping.....this forum is very nice.......
thank you so much....