Link to home
Start Free TrialLog in
Avatar of dandeliondream
dandeliondreamFlag for Singapore

asked on

Visual basic 2003: Convert 'String' to 'Double'

I'm trying to do deployment with strict on.
However, editstudCourse Fee.text is giving me error="option strict on disallows implicit conversions from string to double."
Hope someone can shed some light on this.

    Dim TaxValue As Double = 5
    Dim TaxValueContainer As String

    Dim courseFee As Double = 0
    Dim courseFeeContainer As String

    Dim TaxDisplay As Double
    Dim TaxValueInput As Double
    'Dim noContainer As String
    Dim no1, no2, no3, no4 As Double

...continue

   editstudTaxAmount.Text = editstudCourseFee.Text * TaxValue / 100   <--How to convert editstudCourseFee.Text from 'string' to 'double'
            no1 = Double.Parse(editstudCourseFee.Text)
            no2 = Double.Parse(editstudTaxAmount.Text)
            editstudTotalPayable.Text = Round(no1 + no2, 2).ToString

            no3 = Double.Parse(editstudTotalPayable.Text)
            no4 = Double.Parse(editstudTotalPaid.Text)
            editstudTotalBalance.Text = Round(no3 - no4).ToString
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Hello werD420,

you can use
editstudTaxAmount.Text = Convert.ToDouble(editstudCourseFee.Text) * TaxValue / 100

but why are you converting to double on the next line?

hope this helps a bit
bruintje
ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Tomlinson
Be sure to enclose any of your conversion calls that involve a string to a number data type in a Try...Catch block.  Otherwise your application will crash if the string contains a value that cannot be converted to a valid number.
Avatar of dandeliondream

ASKER

Problem solved. A big thankQ to bruintje and Idle_Mind.
you're welcome :)