I recently discussed this issue under a different question.
See: “VB automatically overrides my capitalization”
Briefly: I made the mistake of naming a variable with a reserved name;
Dim sTR As String.
Str() is a VB function that returns a number as a string.
So, where I had Str(), VB re-capitalized it as sTR (throughout the entire project), and the function stopped working. (Simply returns a blank.)
I renamed my variable, but the Str function stayed broken.
I saved and exited. The next day, upon reload, all the references to Str() were capitalized correctly. And they all worked.
EXCEPT for the specific subroutine where I had initially goofed. In this procedure (only),
sString = Str(iInteger) returned a blank, “”.
Three observations and related questions:
sString = iInteger makes the conversion without invoking the Str() function at all.
Question: Is this good programming practice?
If VB does this, why bother with the Str() function at all?
sString = CStr(iInteger) works just fine.
Question: is CStr() preferable to Str()?
I presume the function Str$() exists for back-compatibility with older versions of Basic
(like Quick Basic).
Question: Is the “$” no longer necessary?