Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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 5:54am
vidkaat544
Comments
richcb at 13-Feb-13 10:57am
   
What kind of file? Store it where?
vidkaat at 13-Feb-13 10:58am
   
its a text file and store it in a dataset.
Chris Reynolds (BNY) at 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 at 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 at 13-Feb-13 11:07am
   
I am stroring it as a Double in my dataset.
Chris Reynolds (BNY) at 13-Feb-13 11:09am
   
Can you post sample contents of your file?
vidkaat at 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
0 OriginalGriff 645
1 Maciej Los 225
2 Abhinav S 171
3 Richard Deeming 160
4 Suvendu Shekhar Giri 159
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,135
2 Peter Leow 5,042
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2015
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