Why doesn't this declaration work in my forms

Why doesn't this declaration work in my forms

Imports microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb
Imports System.IO
Public Class ClassPrimary
Friend s As String = ControlChars.CrLf

Shared Sub main()
Application.Run(New frmStartup)
End Sub

End Class

When I type s in a form it is said to be undeclared.

dennist

[393 byte] By [dennist] at [2008-2-26]
# 1
Because in the above code, 's' is an instance method, and therefore can't be accessed without creating an instance of ClassPrimary.

Put 'Shared' after Friend and then you should be able to do access it via 'ClassPrimary.s'.

DavidM.Kean at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Thanks, but I don't think it's worth the trouble at this point. Maybe for new variables where dim sChar as string = classprimary.s

dennist

dennist at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...