Data conversion

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the difference between these two lines of code.

Feet = Double.Parse(FeetTextBox.Text)

Feet = CDbl(FeetTextBox.Text)

Thanks,

Hilton
 
Hello Hilton,

CDbl is the method available in Microsoft.VisualBasic namespace.
This namespace holds the methods and classes which were available in
previous version of Visual Basic (6).
The implementation of these methods is although in .NET.

Double.Parse is the method in System namespace and this is the core method.

Apparently the VisualBasic version must be using the same method or some
more low level thing.

IMHO if one must avoid the usage of Microsoft.VisualBasic namespace
completely. As this provides an extra level of abstraction and layering.
Besides this was for backward compatibility. Although I am not sure if the
scenario is changed in Whidbey.

Please point out if there is something ambiguoug.

Thank You,
rawCoder.
 
Hi Raw Coder,

Feet = Double.Parse(FeetTextBox.Text)
Backward compatible with C languages

Feet = CDbl(FeetTextBox.Text)
Backward compatible with VB languages

What is the difference, I prefer CDbl because it are less position to type,
why should I only use the single dotNet namespace which is now only
available in the C and J languages.

Just my thought,

Cor
 
hday1 said:
What is the difference between these two lines of code.

Feet = Double.Parse(FeetTextBox.Text)

Feet = CDbl(FeetTextBox.Text)

Double.Parse is a function call. CDBl is not necessarily a function call
because, it is a conversion compiled "inline" wherever possible.
Unfortunatelly, there is no full documentation about all differences, but
one is that CDbl can convert "&H10", whereas Double.Parse can't.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
* "Armin Zingler said:
Double.Parse is a function call. CDBl is not necessarily a function call
because, it is a conversion compiled "inline" wherever possible.
Unfortunatelly, there is no full documentation about all differences, but
one is that CDbl can convert "&H10", whereas Double.Parse can't.

The same for "&O...":

\\\
Dim s As String = "&O23"
MsgBox(CDbl(s)) ' OK.
MsgBox(Double.Parse(s)) ' Exception.
///
 
Back
Top