Convert string to double newbie question

M

mp

I tried looking in help for this but what it said didn't work

from help to cast from one type to another
//i = (int) d; // An explicit conversion, or "cast"

in my code i tried:
(tbDepth is a textbox on a form)

private double m_dDepth =0;
m_dDepth = (double)tbDepth.Text;

compile error
Cannot convert type 'string' to 'double'

how do i convert a string representing a double to a double?

thanks
Mark
 
M

Mr. Arnold

mp said:
I tried looking in help for this but what it said didn't work

from help to cast from one type to another
//i = (int) d; // An explicit conversion, or "cast"

in my code i tried:
(tbDepth is a textbox on a form)

private double m_dDepth =0;
m_dDepth = (double)tbDepth.Text;

compile error
Cannot convert type 'string' to 'double'

how do i convert a string representing a double to a double?
You use the Convert statement which works with strings to convert it over to
a numeric value needed.
 
A

Arne Vajhøj

I tried looking in help for this but what it said didn't work

from help to cast from one type to another
//i = (int) d; // An explicit conversion, or "cast"

in my code i tried:
(tbDepth is a textbox on a form)

private double m_dDepth =0;
m_dDepth = (double)tbDepth.Text;

compile error
Cannot convert type 'string' to 'double'

how do i convert a string representing a double to a double?

double.Parse or possible even better double.TryParse!

Arne
 
M

mp

Konrad
Thank you for the response.
i think my help is not set up right in express - i find this online but not
in local
Thanks again,
Mark
 

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