How save a number(decimal) in a file?
Posted on 2003-03-15
I have the following problem:
I try to save a variable (single) to a file an my harddrive.
I have tried different methods and nothing worked.
so: for example: I have an variable (dim getal as single).
The user can input (using the textbox (text1.text)) an decimal number.
for example: getal=text1.text
I have tried to save this decimal using 2 methods:
the first thing i tried was with the:
OPEN ****** FOR OUTPUT AS 1
PRINT #1, ******
The second thing i tried was:
OPEN "**********" FOR RANDOM AS 1 LEN = 6
PUT 1, 1, getal
these two codes didn't save the numeric data how it should be.
when i tried the second thing: I entered the number 12.6
afterwards when i opened the file again, it was saved as 126 instead of 12.6
Can someone help me with this?? I'm a beginner in VB.
I try to make a simple cashregister. So I should be able save variables containing decimals and close the program. Then start the program again and get the proper variable from a saved file.
It should also be able to make calculations with that variable after it is opened again.
Thanx in advance