4 Replies - 575 Views - Last Post: 24 June 2013 - 07:03 AM Rate Topic: -----

#1 man007  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 22-June 13

Convert string to double?

Posted 24 June 2013 - 06:18 AM

Hello,
I am trying to convert a number that it is saved as string to double. The problem is that when I am trying to do it the number change... For example if I have the number 1.1 in a string and I put it to a double the number becomes 11...
Moreover when I am trying to convert the string to double with the function Convert.ToInt64 I am getting the error below :
"Input string was not in correct format"
Is This A Good Question/Topic? 0
  • +

Replies To: Convert string to double?

#2 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: Convert string to double?

Posted 24 June 2013 - 06:26 AM

try using
CDbl(string goes here)


Edit forget what i said do it hawks way it's better.

This post has been edited by m_wylie85: 24 June 2013 - 06:30 AM

Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1062
  • View blog
  • Posts: 4,138
  • Joined: 02-July 08

Re: Convert string to double?

Posted 24 June 2013 - 06:28 AM

Show some code. You should be using the Double.TryParse method for converting a string to double.
Was This Post Helpful? 0
  • +
  • -

#4 man007  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 22-June 13

Re: Convert string to double?

Posted 24 June 2013 - 06:45 AM

I still have the same problem... I am getting 11 and not 1.1 from the 1.1 string...
Here is an example of my program :
Dim A(10) As Double
Dim fl As String =  My.Computer.FileSystem.ReadAllText("PATH")
Dim i as Integer = 0
For Each b as string In fl.Split("|")
A(i) = b
i = i + 1
Next


The fl contains numbers spited by |. But the command on line 5 has the problem I described above no matter what I try...
Was This Post Helpful? 0
  • +
  • -

#5 man007  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 22-June 13

Re: Convert string to double?

Posted 24 June 2013 - 07:03 AM

Edit : I did it with HAWK's methos! Thank you guys!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1