App_Code Class

How can I place the attached Function in the App_Code folder and a class called "myMethods" so it is accessible site wide instead of copying into every page?
Function RemoveNonDigits(ByVal s As String) As String
        Dim regex As New System.Text.RegularExpressions.Regex("[^\d]")
        RemoveNonDigits = regex.Replace(s, "")
    End Function

Open in new window

Larry Bristersr. DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

derftoyCommented:
In VB instead of a class, create a class file and create a Public Module instead of Public Class and put your function in it.
0
Larry Bristersr. DeveloperAuthor Commented:
derftoy:
I recognized the words and idea...got an example?

I'm in Visual Studio 2008 and it's a Web Site
0
derftoyCommented:
In your app code folder add a new class.  It will default to something like class.vb... name the file whatever you want.  Just remove the class declaration inside the file and replace with the Public Module like I show witht he code below.  

Replace the generated Class code with Public Module and put your functions in it.  Make sure your functions are public as well.  You will then be able to call those functions within your app from anywhere.

I have attached some code I use with some constants and such.
Public Module LoginCode
    Public Const APP As String = "PERMITTRAX"
    Public Const BAR_X As Integer = 760
    Public Const BAR_YUP As Integer = 130
    Public Const BAR_YDN As Integer = 530
    Public Const APPDBVER As String = "02162010"
    Public Const RPTVER As String = "01202010"

    Public Function CheckDBVersion(ByVal CONID As String) As Boolean
        Dim i As New DataIO
        Dim bReturnVal As Boolean = False

        i.OpenDS("SELECT * FROM Console_Settings WHERE Setting_Option = 'APPDBVER'", GetAppConnection(CONID))
        If i.RecCount = 0 Then
            i.DSCommand(DataIO.DSCommands.AddRecord)
            i.PutField("Setting_Option", "APPDBVER")
            i.PutField("Field_Text_1", APPDBVER)
            i.PutField("Setting_Desc", "Application Database Version")
            i.DSCommand(DataIO.DSCommands.UpdateRecord)
            bReturnVal = True
        Else
            ' Check Version
            If i.GetField("Field_Text_1").ToString <> APPDBVER Then
                bReturnVal = False
            Else
                bReturnVal = True
            End If
        End If
        i.CloseDS()

        Return bReturnVal
    End Function

    Public Function ValidateRegistration(ByVal ID As String) As Boolean
        Dim i As New DataIO
        Dim cn As New Connections

        Try
            If ID = "" Then Return False
            i.OpenDS("SELECT * FROM APP_Registration WHERE AutoKey = " & ID, cn.GetConString(Connections.APPS.APPLICATION))
            If i.RecCount <> 0 Then
                If Not IsDate(i.GetField("Reg_Completed")) Then
                    Exit Try
                End If
            End If
            i.CloseDS()
        Catch ex As Exception
            Return False
        End Try

        Return True
    End Function

End Module

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Larry Bristersr. DeveloperAuthor Commented:
Thanks...that's it.  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.