How to Convert String to Double Visual Basic

Save

Conversion of variables to different types is an integral part of computer programming. The functions included in Visual Basic make this an easy and painless task. Mastering conversion functions will allow you to develop more complex, better designed and more efficient applications.Converting data from a string to double may be required when allowing users to input data and then perform mathematical calculations. This technique is one of the simplest and easy to understand for the beginning developer.

Things You'll Need

  • Visual Basic 2008 Express Edition
  • Open up Visual Basic and create a "Windows Form Application" project.

  • Create a button on the new form.

  • Double click on the button object you added to the form.

  • Insert the following code:

    Dim double1 As Double
    Dim string1 As String

    string1 = "19.99"
    double1 = CDbl(string1)
    MsgBox(double1) ' prints 19.99

  • Press the "F5" key to execute the code.

  • Click on the button and a message box will appear on the screen with the value of the double variable displayed as a string.

References

Promoted By Zergnet

Comments

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!