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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaration expected 1

Status
Not open for further replies.

mancroft

Programmer
Oct 26, 2002
267
GB
Hello

I have added a new windows form to the project and put in the lines (see below) BUT this line here:

Code:
 mywriterdefaultsettings.WriteLine("TWO")

generates an error "Declaration expected"

Any idea as to the cure?

Thank you.

Code:
Public Class defaultsettings

 Dim thestringstart2 As String = ""
 Dim thestringend2 As String = "defaultsettings.txt"
 Dim thefilepath2 As String = thestringstart2 & thestringend2

 Dim myfilestream2 As New System.IO.FileStream(thefilepath2, IO.FileMode.Append, IO.FileAccess.Write)

 Dim mywriterdefaultsettings As New System.IO.StreamWriter(myfilestream2)

 mywriterdefaultsettings.WriteLine("TWO")

End Class
 
Try changing:

Dim mywriterdefaultsettings As New System.IO.StreamWriter(myfilestream2)


to:

Public Shared mywriterdefaultsettings As New System.IO.StreamWriter(myfilestream2)


Hope this helps.

[vampire][bat]
 
The line in question should be placed in a function, sub or property. The complier is looking for declarations in the section you have it currently.
Hope this helps
Steve
 
This works... duh!

Public Sub defaultsettings(ByVal sender As System.Object, ByVal e As System.EventArgs)
mywriterdefaultsettings.WriteLine("INSIDE TWO")
End Sub
 
mancroft why are you using the sender and e parameters?

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top