How to convert a string to a decimal in VB.NET

1 Answer

0 votes
Imports System

Public Class Program
	Public Shared Sub Main()
        Dim str As String = "378483.901"
        Dim dec As Decimal

        If Decimal.TryParse(str, dec) Then
            Console.WriteLine("{0}, {1}", dec, dec.[GetType]())
        Else
            Console.WriteLine("Conversion Error")
        End If
    End Sub
End Class




' run:
'
' 378483.901, System.Decimal
'

 



answered Aug 4, 2022 by avibootz
...