VB : CDbl Function

Posted by Fluffy | 7:12 AM | , , | 0 comments »

Using CDbl Function in VB


CDbl function is used to convert a data into Double data type. See the simple example illustrated below for a better understanding of this CDbl function. The example below converts a data stored in a textbox and convert it into Double data type.



Dim Output As Double '---- Declaring Variable

TextBox1.Text = "234.456784" '--- Initialize the figure as a string stored in a textbox

Output = CDbl(Val(TextBox1.Text) * 3.142 * 10/100) '- Run the formula of multiplying the figure with pi, and then multiply it again by 10%.

MsgBox(Output) '-- The output retrieved will be 73.6663215328


Hope you could now be able to know how you can use this CDbl function and apply in your VB codes.

See Also CType Functions

0 comments