ScaryDef
ScaryDef

Reputation: 1

Avoid scientific notation with doubles in VB

I'm working on this project, in Visual Basic:


   Sub Main()
           Dim i As Integer, j As Double
           i = 1
           Dim fileReader =
               My.Computer.FileSystem.OpenTextFileReader("C:\text.txt")
           For i = 1 To 3
               Dim stringReader = fileReader.ReadLine()
               j = j + CDbl(stringReader)
           Next
           Debug.Print(j)

End Sub

Which is supposed to read the first three lines of a text file containing:

37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629

Now when these numbers are added up, and the result is printed, it gives me scientific notation, so here is my question:

Is there a way I can make the program write the whole number without scientific notation, AND all the significant figures, I seem to get a problem where past 10 ~ 12 digits it's just all 0.

I know similar questions have been asked but I can't seem to find an answer to apply to my case, so I'm sorry if it is a duplicate.

Upvotes: 0

Views: 3006

Answers (1)

Hemal
Hemal

Reputation: 3760

You can use something like this. This will avoid E exponential format of numbers.

YourNumber.ToString(".################") 'No of digits = No of hashes #

Upvotes: 2

Related Questions