Need Help with Syntax

Bernie

Well-known member
Joined
Aug 13, 2007
Messages
98
Programming Experience
3-5
I found this code on the net;
VB.NET:
Private Function fGetCaption(Hwnd As Long) As String
    Dim strBuffer As String
    Dim intCount As Integer

    strBuffer = String$(mconMAXLEN - 1, 0)
    intCount = apiGetWindowText(Hwnd, strBuffer, mconMAXLEN)
    If intCount > 0 Then
        fGetCaption = Left$(strBuffer, intCount)
    End If
End Function

What is the use of the "$"? The author used this twice;

String$(mconMAXLEN - 1, 0)
Left$(strBuffer, intCount)

All I can think of is the single charactor matching wildcard. What am I missing here?

Bernie
 
That is not VB.Net code, it's classic VB, the "Hwnd As Long" is the main tell-off, window handles are IntPtr which is 32bit integers on 32bit platforms.

In VB.Net you would usually use the String class instead of those string functions (the $ was to say it was a function returning a string), for example:
VB.NET:
Dim s As New String("s"c, 15) 'creates a new string with 15 "s" characters
s = s.Substring(0, 5) 'returns the 5 first (left) characters in string
 
Back
Top