Using CDec Function in VB
CDec is used to convert data into Decimal data type. The example below briefly illustrates how CDec function can be used in Visual Basic programming code.
Dim myData As Integer '--- Declare the variables
Dim Output As Decimal
myData = 79 '--- Initialize data value
Output = CDec((myData - 32) * (7 / 3) * (5 / 9)) '---Convert data into Decimal data type
MsgBox(Output) '-The output is 60.9259259259259
As can be seen in the above example illustration, there is technically no difference between conversion of the data into either Decimal data type or Double data type. The only difference that both the data type Decimal and Double is that Decimal has its value fixed at a base of 10 whereas Double is a floating point number base of 2. That is, they differs only in the precisions & ranges of the value.
See Also CType Function
Subscribe to:
Post Comments (Atom)

0 comments
Post a Comment