Click here to Skip to main content
12,349,884 members (23,245 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
Hi All,

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

Thanks.
Posted 13-Feb-13 4:54am
vidkaat570
Comments
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
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,

try by writing the below function and pass the text read from the file.
Private Function fnGetNumber(text As String) As Double
	Try
		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.
  Permalink  

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


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2016
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