why are my public functions not accessible.

I am writting a wp7 app that has 2 pages (MainPage and Setttings).  I am using a couple of public functions  (AllowNumbersAtStart and AllowSymbolsAtStart) that I have placed in a class  called AppSettings.  For some reason I can only accesss them from Settings.xaml.vb and not MainPage.xaml.vb.  What am I missing?  I thought this would work like normal VB.Net.  I have tried for ex. AllowNumbersAtStart and AppSettings.AllowNumbersAtStart.
Imports System.IO.IsolatedStorage
Imports System.Diagnostics
Imports System.Collections.Generic


Public Class AppSettings
    Dim isolatedstore As IsolatedStorageSettings = IsolatedStorageSettings.ApplicationSettings 'get the settings for the app.

    Public Sub AppSettings()

    End Sub

    Public Function GetValueOrDefault(ByVal key As String, ByVal defaultValue As ValueType) As ValueType
        Dim value As ValueType

        Try
            'value = DirectCast(isolatedstore(key), ValueType)
            value = CType(isolatedstore(key), ValueType)
            'value = isolatedstore.TryGetValue(key, defaultValue)
        Catch ex As KeyNotFoundException
            value = defaultValue
        Catch ex As ArgumentException
            value = defaultValue
        Catch ex As NullReferenceException
            value = defaultValue
        End Try
        Return value
    End Function

    Public Function AddOrUpdateValue(ByVal key As String, ByVal value As Boolean) As Boolean
        Dim valueChanged As Boolean = False

        Try
            'if new value is different. set the new value.
            If CBool(isolatedstore(key)) = value Then
                isolatedstore(key) = value
                valueChanged = True
            End If
        Catch ex As KeyNotFoundException
            isolatedstore.Add(key, value)
            valueChanged = True
        Catch ex As ArgumentException
            isolatedstore.Add(key, value)
            valueChanged = True
        Catch ex As NullReferenceException
            isolatedstore.Add(key, value)
            valueChanged = True
        Catch ex As Exception
            MessageBox.Show("Exception while using IsolatedStorageSettings " & ex.Message)
        End Try

        isolatedstore.Save()

        Return valueChanged
    End Function

    Public Property AllowNumbersAtStart() As Boolean

        Get
            Return CBool(GetValueOrDefault("AllowNumbersAtStart", False))
            'Return CBool(isolatedstore.TryGetValue(AllowNumbersAtStartkeyName, AllowNumbersAtStartDefault))
        End Get
        Set(value As Boolean)
            AddOrUpdateValue("AllowNumbersAtStart", value)
        End Set
    End Property

    Public Property AllowSymbolsAtStart() As Boolean
        Get
            Return CBool(GetValueOrDefault("AllowSymbolsAtStart", False))
            'Return CBool(isolatedstore.TryGetValue(AllowNumbersAtStartkeyName, AllowNumbersAtStartDefault))
        End Get
        Set(value As Boolean)
            AddOrUpdateValue("AllowSymbolsAtStart", value)
        End Set
    End Property

End Class

Open in new window

NevSoFlyAsked:
Who is Participating?
 
käµfm³d 👽Commented:
You would use AppSettings.AllowNumbersAtStart if you had declared the AllowNumbersAtStart method to be Shared. What you need to do is declare an instance of you class (or mark it Shared if you want to keep the aforementioned syntax). For example:

Dim appSet As New AppSettings()

appSet.AllowNumbersAtStart()

Open in new window

0
 
NevSoFlyAuthor Commented:
By the way the error that I get when trying to call the function from MainPage.xaml.vb is :
'AllowNumbersAtStart' is not declared. It may be inaccessible due to its protection level.

I know the answer will be a stupidly simple one but I just don't see it.
0
 
NevSoFlyAuthor Commented:
Totally embarrassed here.  I will blame it on only 2 hrs sleep in over 30 hrs and just looking at the same screen too long.  Thx.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.