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.

[301 byte] By [elainel311] at [2007-12-24]
# 1

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.

ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2
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 Starter

Kits. Also there are 101 Samples for

Visual Studio 2005 which is a robust, initial development

tasks to more involved tasks for winforms, web development

etc.

OmegaMan at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3
Thank you for your help.
elainel311 at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...