Hi,
I am simply trying to create a library of common functions I've written. I used the 'Class Library' template project.
But I'm running into issues with member accessibility. Because I DON'T want to instance this library, as its purely a namespace, I was making class members (functions) 'SHARED' for the time being (for testing).
But this can't be the way a namespace is written. Now I have problems accessing private members in the class from within a shared function.
What is the way to approach this?
Code:Namespace CustomFunctions Public Class Str 'there are mutliple classes within this namespace to organize the entire library Shared Function HasAlpha(ByVal Str As String) As Boolean 'check for alphabetic characters For i = 0 To Str.Length - 1 If Char.IsLetter(Str.Chars(i)) Then Return True End If Next Return False End Function Shared Function IsNumeric(ByVal Str As String) As Boolean 'check if only numbers For i = 0 To Str.Length - 1 If Not Char.IsNumber(Str.Chars(i)) Then Return False End If Next Return True End Function Shared Function CountChar(Str As String, Character As String) As Integer 'count characters in string Dim count As Long For Each c As Char In Str If c = Character Then count = count + 1 End If Next Return count End Function End Class End Namespace




Reply With Quote
