dandeliondream
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(editstudCours eFee.Text)
no2 = Double.Parse(editstudTaxAm ount.Text)
editstudTotalPayable.Text = Round(no1 + no2, 2).ToString
no3 = Double.Parse(editstudTotal Payable.Te xt)
no4 = Double.Parse(editstudTotal Paid.Text)
editstudTotalBalance.Text = Round(no3 - no4).ToString
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(editstudCours
no2 = Double.Parse(editstudTaxAm
editstudTotalPayable.Text = Round(no1 + no2, 2).ToString
no3 = Double.Parse(editstudTotal
no4 = Double.Parse(editstudTotal
editstudTotalBalance.Text = Round(no3 - no4).ToString
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
Problem solved. A big thankQ to bruintje and Idle_Mind.
you're welcome :)
you can use
editstudTaxAmount.Text = Convert.ToDouble(editstudC
but why are you converting to double on the next line?
hope this helps a bit
bruintje