This looks funnyCode:msgbox getDesktopPath
msgbox getDesktopPath & "\file1.dat"
Printable View
This looks funnyCode:msgbox getDesktopPath
msgbox getDesktopPath & "\file1.dat"
I presume that the function getDesktopPath returns a string ending with a Chr(0) character (as many API calls do), which marks the end of a string for most controls etc - in which case it is not a bug at all, just 'bad' code.
If you show us the code for getDesktopPath, we can help you correct it.
Code:Public Declare Function SHGetSpecialFolderPath Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" (ByVal hwnd As Long, ByVal pszPath As String, ByVal csidl As Long, ByVal fCreate As Long) As Long
Public Function getDesktopPath() As String
Dim sPath As String
sPath = Space$(255)
SHGetSpecialFolderPath hwnd, sPath, 0, 0
getDesktopPath = sPath
End Function
As SI said, the API returns a null terminated string, so you need to get rid of the null character:
The reason I added the trim is because the string will be 255 characters long after we remove the null.Code:getDesktopPath = Trim$(Replace(sPath, Chr(0), ""))