Click here to Skip to main content
12,948,567 members (63,035 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All,

I need to read the value -0000000334017 from a file and store them as -3340.17 in application.How can i do that?Please help.

Posted 13-Feb-13 4:54am
richcb 13-Feb-13 10:57am
What kind of file? Store it where?
vidkaat 13-Feb-13 10:58am
its a text file and store it in a dataset.
Chris Reynolds (BNY) 13-Feb-13 10:59am
Is the value held as a string in your file? Is it the only thing in the file?
If it is a string then using the TryParse functions to convert it into a number and then dividing the result by 100 would be one way of doing it.
vidkaat 13-Feb-13 11:04am
Nope.Its not the only thing in the file i retrieved other data from the file like name,id and stuff.Not sure how to retrieve this value.

I tried row.Substring(87,11) but could not get them.
vidkaat 13-Feb-13 11:07am
I am stroring it as a Double in my dataset.
Chris Reynolds (BNY) 13-Feb-13 11:09am
Can you post sample contents of your file?
vidkaat 13-Feb-13 11:09am
I cannot its a confidential file.Sorry.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


try by writing the below function and pass the text read from the file.
Private Function fnGetNumber(text As String) As Double
		Return (Convert.ToDouble(text.Trim())) / 100
	Catch ex As Exception
		Return 0.0
	End Try
End Function

this function will the double value and if the text is in correct, this will return 0.0 and also, this will give number with 2 decimal places.

hope it helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,419
CHill60 3,275
Maciej Los 2,778
Jochen Arndt 1,935
ppolymorphe 1,795

Advertise | Privacy | Mobile
Web02 | 2.8.170524.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100