Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Shared Member Error 1

Status
Not open for further replies.

TheFitz

Programmer
Dec 18, 2003
140
GB
I'm new to VB.NET, however I'm a relatively experienced VB Programmer. I'm part way through creating my first Project and I seem to be having a little problem with some code.

I am getting the following error message:

Code:
Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

It is placing the error on 2 lines and a selection of the code is as follows:

Code:
        Dim objSysFile As System.IO.File
        Dim objWrite As System.IO.StreamWriter

 . . . . . .

        If Dir(Application.StartupPath & "\SysLog\" & strFilename) = strFilename Then
            [b]objWrite = objSysFile.AppendText(Application.StartupPath & "\SysLog\" & strFilename) [/b]
        Else
            [b]objWrite = objSysFile.CreateText(Application.StartupPath & "\SysLog\" & strFilename) [/b]
            objWrite.WriteLine("{0,8}{1,6}{2,2}{3,10}{4,255}", "|-Date-|", "|Time|", "||", "|-UserID-|", "Message" & Space(248))
        End If

I'm sure this is really easy to fix and probably just inexperience with VB.NET, but I'm stumped.

Suggestions would be very useful.

Many thanks for any comments in advance,


Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
System.IO.File does not have any public contructors; therefore you can't create any instances of that type. It consists solely of Shared methods -- no need for objSysFile. Just replace "objSysFile" with "System.IO.File" to access the .AppendText and .CreateText methods.
 
Perfect!!! That's excellent, many thanks

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top