newbie question ?Syntax

  • Thread starter Thread starter Joisey
  • Start date Start date
J

Joisey

This is part of the code I downloaded to retrive a string value from a .ini
file:
(I have NOT shown all the lines which declare the API functions and
properties)

Public Function GetString(ByVal Section As String, ByVal Key As String,
ByVal [Default] As String) As String

' Returns a string from your INI file

Dim intCharCount As Integer

Dim objResult As New System.Text.StringBuilder(256)

intCharCount = GetPrivateProfileString(Section,
Key, [Default], objResult, objResult.Capacity, strFilename)

If intCharCount > 0 Then GetString =
Left(objResult.ToString, intCharCount)

End Function

In the last line, the word "Left" is underlined and the error message is
shown as:
Reference to a non-shared member requires an object reference.

Can anyone direct me to information to fix this. I have many very thick
textbooks, with very poor indexes which
do not direct me to this particular error.
thanx.....joisey
 
Joisey said:
Public Function GetString(ByVal Section As String, ByVal Key As String,
ByVal [Default] As String) As String

' Returns a string from your INI file

Dim intCharCount As Integer

Dim objResult As New System.Text.StringBuilder(256)

intCharCount = GetPrivateProfileString(Section,
Key, [Default], objResult, objResult.Capacity, strFilename)

If intCharCount > 0 Then GetString =
Left(objResult.ToString, intCharCount)

End Function

In the last line, the word "Left" is underlined and the error message is
shown as:
Reference to a non-shared member requires an object reference.


Use 'Strings.Left' instead of 'Left'.
 
Back
Top