how to convert string to double datatype using VB.net

S

Scott M.

Family Tree Mike said:
double.TryParse() would be a useful function for this.

dim x as double
if (double.TryParse("3.14159265", out x)) then
Console.WriteLine("Got Pi")
else
Console.WriteLine("Error getting Pi...")
endif

Correction, for VB .NET it is:

Dim pi As Double
If Double.TryParse("3.14159265", pi) Then
Console.WriteLine("Got Pi")
Else
Console.WriteLine("Error getting Pi...")
End If

-Scott
 
F

Family Tree Mike

Scott M. said:
Correction, for VB .NET it is:

Dim pi As Double
If Double.TryParse("3.14159265", pi) Then
Console.WriteLine("Got Pi")
Else
Console.WriteLine("Error getting Pi...")
End If

-Scott

Oops! Some C# jumped into my vb...

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top