Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert label to double 1

Status
Not open for further replies.

mancroft

Programmer
Oct 26, 2002
267
GB
Hello

How do I convert a label to a double?

thedouble = thelabel

and

thedouble = CDbl(thelabel)

appear not to work.

Thank you.
 
theDouble = Convert.ToDouble(theLabel.Text)

Convert is in the System namespace, so you generally always have access to it. :)

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Chip, is there any difference between

theDouble = CDbl(theLabel.Text)

which I would have used, and your suggestion?

[vampire][bat]
 
I believe that they end up being the same IL code (give or take). CDbl() is from the VB.NET language spec, while the Convert class is from the framework itself.

If you ever intend to learn one of the other .NET languages (J#, C#, COBOL.NET, etc), then it might be a good idea to learn more about the framework, and use the framework methods where possible.

If you're curious, you can write some code to illustrate each, and once it's compiled, run it through ildasm.exe (comes with the framework) or Reflector ( to view the IL code that gets produced by the compiler, and see which is more efficient.

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top