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.
How to Convert a String to a Number in Visual Basic
Visual Basic (VB) is a programming language used to create desktop and website applications. One common part of VB programming is converting...
How to Convert an Object to String in Visual Basic
Visual Basic is a compiler used to program desktop and website applications. Objects in Visual Basic are components of a form such...
How to Convert String to Date Objects
String conversions provide a way for a software developer to switch data types in website code. The conversion from a string to...
How to Copy to Clipboard in Visual Basic
The clipboard is an area of memory in Windows that is set aside to allow users and applications to move text, images,...
How to Clean a String in VBA
As a Visual Basic for Applications programmer, you should be able to remove numbers or characters in strings to display correct information...
How to Convert Double to String C++
C++ handles a variety of conversions between number types and strings using the iostream class and the put-to operator "<<." The iostream...
How to Output a String in Visual Basic
In computer programming, the String variable is widely used to capture and output data among variables or controls. In Visual Basic, you...
How to Use TryParse in Visual Basic
Many of the numbers that you see in computer applications are actually strings. For example, a "Quantity" text box on a Web...
How to Convert a Textbox to a Number in Visual Basic
Microsoft's Visual Basic contains some powerful functions that make the programmer's life easier. One such example is the ability to convert data...