Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2006-04-09
Medium Priority
Last Modified: 2013-11-25
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


   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
Question by:dandeliondream
  • 3
LVL 44

Expert Comment

ID: 16412097
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
LVL 44

Accepted Solution

bruintje earned 1000 total points
ID: 16412101
and you probably need to reconvert after the calculation
editstudTaxAmount.Text = Convert.ToString(Convert.ToDouble(editstudCourseFee.Text) * TaxValue / 100)
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16412255
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.

Author Comment

ID: 16414756
Problem solved. A big thankQ to bruintje and Idle_Mind.
LVL 44

Expert Comment

ID: 16414827
you're welcome :)

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question