 |

11-27-2003, 03:30 AM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Sri Lanka
Posts: 13
|
|
help
|
how can I save a number to a required format in a file
Thanks
|
|

11-27-2003, 03:38 AM
|
 |
Senior Contributor
|
|
Join Date: Dec 2002
Location: Netherlands
Posts: 867
|
|
|
What do you mean?? Writing a number/text to a file has been discussed many times on this forum. If that is what you mean have a search for 'writing files'.
Wilbert
|
|

11-27-2003, 04:33 PM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Sri Lanka
Posts: 13
|
|
Quote: Originally Posted by wilbert What do you mean?? Writing a number/text to a file has been discussed many times on this forum. If that is what you mean have a search for 'writing files'.
Wilbert
I have some values/numbers entered through the key board and I want to save those numbers to a predefined format,
Ex, If I enter 3,4.5,6,7.2 I like to save these numbers
3.0 4.5 6.0 7.2
I used the following method for that,
if the values are stroed in c, g, etc.
c_string = format (c,"####.####)
g_string =format (g,"####.####)
etc...
print #3, c_string;g_string
But this did not work
Thanks
|
|

11-27-2003, 04:35 PM
|
 |
Ultimate Contributor
Retired Leader * Guru *
|
|
Join Date: Aug 2001
Posts: 5,343
|
|
|
Can you paste some actual code?
|
|

11-27-2003, 06:17 PM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Sri Lanka
Posts: 13
|
|
Quote: Originally Posted by VolteFace Can you paste some actual code?
Hello
This is the code I used
Open "fort101.dat" For Output As #3
Print #3, np_block - 1
For i = 1 To np_block
ii = Format(i, "#####")
xx = Format(xp(i), "####.#####")
yy = Format(yp(i), "####.#####")
Print #3, ii; xx; yy
Me.Caption = xx
Next i
For i = 1 To np_block - 2
ii = Format(i, "#####")
xx = Format(xc(i), "####.#####")
yy = Format(yc(i), "####.#####")
Print #3, ii; xx; yy
Next i
Print #3, "0"
c_print = Format(c, "####.#####")
fai_print = Format(fai, "####.#####")
gamma_print = Format(gamma, "####.#####")
Print #3, fai_print; c_print; gamma_print
Print #3, "0.0"
Close #3
I am expecting to use this file in a previously developed program in Fortran. It needs to read data using formatI5,F10.3 etc...
Thanks
|
|

11-27-2003, 06:24 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Jun 2003
Location: A room without Windows
Posts: 896
|
|
|
For Fixed Length / Decimal Place formatting use 0 not #
Format(12.345,"#####.#####") will give 12.345
Format(12.345,"00000.00000") will give 00012.34500
HTH
|
__________________
Dan B
"Don't anthropomorphize computers. They don't like it."
Trig is for wuss's - Coordinate Geometry RULES!
|

11-27-2003, 06:42 PM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Sri Lanka
Posts: 13
|
|
Quote: Originally Posted by DaftasBrush For Fixed Length / Decimal Place formatting use 0 not #
Format(12.345,"#####.#####") will give 12.345
Format(12.345,"00000.00000") will give 00012.34500
HTH
Hello !
Thanks for the advice. I tried that as well, but I want to have numbers without un-necessry "0's" if possible.
Otherwise, with extra zeros the program is running now.
Thanks for the point
Jayalath 
|
|

11-27-2003, 06:45 PM
|
 |
Ultimate Contributor
Retired Leader * Guru *
|
|
Join Date: Aug 2001
Posts: 5,343
|
|
|
How about if you format it with "#.00"?
|
|

11-27-2003, 07:07 PM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Sri Lanka
Posts: 13
|
|
Quote: Originally Posted by VolteFace How about if you format it with "#.00"?
Hello !
No it does not work.....It will not leave blank spaces for required length.
Thanks for your concern
Jayalath
|
|

11-27-2003, 07:08 PM
|
 |
Ultimate Contributor
Retired Leader * Guru *
|
|
Join Date: Aug 2001
Posts: 5,343
|
|
When I do this:
Code:
MsgBox Format(4, "#.0")
It shows 4.0 -- is this not what you want, or am I totally mistaken?
|
|

11-28-2003, 03:05 AM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Sri Lanka
Posts: 13
|
|
Quote: Originally Posted by VolteFace When I do this:
Code:
MsgBox Format(4, "#.0")
It shows 4.0 -- is this not what you want, or am I totally mistaken?
As long as there are numbers, it follows the condition given by '#', otherwise, it will not leave any spaces as we want. For '0's it will att extra '0's to the length indicated by format.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|