FIX: CSng Converted to CDbl for String Literals and Variables (127031)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 3.0
- Microsoft Visual Basic Professional Edition for Windows 3.0
This article was previously published under Q127031 SYMPTOMS
Code using the function CSng() within Visual Basic is automatically
converted to a CDbl by the compiler.
CAUSE
If a string literal, such as 1.1, or a string variable is placed inside of
the CSng function, Visual Basic converts the function to CDbl. The
following code demonstrates the problem:
Dim S As Single S=CSng("1.1")
When you run a program containing this code, Visual Basic changes it to
this code:
Dim S As Single S=CDbl("1.1")
WORKAROUND
To work around the problem, use another function that operates on the
string. Then place this result inside the CSng function. For example, use
this:
S=CSng(Val("100"))
STATUS
This bug was corrected in Microsoft Visual Basic version 4.0 for Windows.
Modification Type: | Major | Last Reviewed: | 10/29/2003 |
---|
Keywords: | kbbug kbfix KB127031 |
---|
|