none
Why doesn't this declaration work in my forms

    Question

  • 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

    Saturday, May 07, 2005 7:25 AM

Answers

  • 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'.
    Saturday, May 07, 2005 7:40 AM
    Moderator

All replies

  • 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'.
    Saturday, May 07, 2005 7:40 AM
    Moderator
  • 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
    Saturday, May 07, 2005 7:53 AM