newbie question ?Syntax

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
 
H

Herfried K. Wagner [MVP]

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'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Reading an INI file 18
GetPrivateProfileString problem! 1
GetProfileItem. 7
Variable Declaration Problem 6
Shared functions not accessible 10
ini file 2 2
Crypto Question 2
INI File 5

Top