Please help with save/open,rounding off.
Hi
Can someone please help me, I'm new to visual basic.
I would like to know how does one code save or open and what file format would be best?
How do I stop the program from rounding off calculations, e.g. 12.50 to 13.00. I want it to show 12.50.
Thank you very much.
well what type of file do you want to save?
Here is an example on saving to a text file:
'Import the System.IO namespace
..
..
Dim theStreamWriter as new StreamWriter(Application.StartupPath & "\filename.txt")
theStreamWriter.Write("hello!")
theStreamWriter.Close()
to append to the file, set the second parameter of the StreamWriter constructor to "true"
to load a file:
Dim theStreamReader as new StreamReader(Application.StartupPath & "\filename.txt")
dim theText as string = theStreamReader.ReadToEnd()
theStreamReader.Close()
would read everything into a string. It depends what you wish to do.
how are you rounding off calculations? IF you are using Math.Round then this is what it will do.
If you are doing financial calculations, you will want to use the decimal type. Float will present problems after 15 significant digits see a
post I did on double weirdness...but it should be fine for two. <g>
Examples are some of the best way to learn. Check out some of the VB/C#examples
for the basic operations or some more robust
examples as found in the StarterKits
. Also there are 101 Samples forVisual Studio 2005
which is a robust, initial development
tasks to more involved tasks for winforms, web development
etc.