define global value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • .nLL

    define global value

    hi, im new to asp.net and trying to define a global value. i dont want to
    use web.config because i want to be able to run my app on any sub folder
    without created an application in iis.

    so far i got below in my functons.vb

    ------------------------
    Public Class MyFunctions
    Public Shared Function MyDbPath() As String
    Return "Provider=Micro soft.Jet.OLEDB. 4.0;Data
    Source=|DataDir ectory|bookmark s.mdb;User Id=admin;Passwo rd=;"
    End Function


    Public Shared Function AlphaNumOnly(By Val MyString As String) As String
    Dim sResult As String
    sResult = Trim(MyString)
    If Not sResult = "" Then
    sResult = Regex.Replace(M yString, "[^a-z|A-Z|0-9|\.|\-]{1,50}",
    "")
    End If

    Return sResult
    End Function
    end class
    ----------------------------------------------

    i can use AlphaNumOnly function anywhere within my code and works fine but
    when i try to use myfunctions.MyD bPath() i get error saying ' MyDbPath is
    not member of MYNameSpace.Myf unctions

    I can;t see what im doing wrong.

    thanks

  • Jonathan Wood

    #2
    Re: define global value

    Although I use C# and may potentually miss some nuances of VB.NET, I don't
    see the difference. I suspect that the problem is somewhere other than the
    code you posted. Let's see the reference that fails and the exact error
    message.

    --
    Jonathan Wood
    SoftCircuits Programming


    ".nLL" <noone@here.com wrote in message
    news:3Pcsk.6509 $_M4.4969@newsf e18.ams2...
    hi, im new to asp.net and trying to define a global value. i dont want to
    use web.config because i want to be able to run my app on any sub folder
    without created an application in iis.
    >
    so far i got below in my functons.vb
    >
    ------------------------
    Public Class MyFunctions
    Public Shared Function MyDbPath() As String
    Return "Provider=Micro soft.Jet.OLEDB. 4.0;Data
    Source=|DataDir ectory|bookmark s.mdb;User Id=admin;Passwo rd=;"
    End Function
    >
    >
    Public Shared Function AlphaNumOnly(By Val MyString As String) As String
    Dim sResult As String
    sResult = Trim(MyString)
    If Not sResult = "" Then
    sResult = Regex.Replace(M yString, "[^a-z|A-Z|0-9|\.|\-]{1,50}",
    "")
    End If
    >
    Return sResult
    End Function
    end class
    ----------------------------------------------
    >
    i can use AlphaNumOnly function anywhere within my code and works fine but
    when i try to use myfunctions.MyD bPath() i get error saying ' MyDbPath is
    not member of MYNameSpace.Myf unctions
    >
    I can;t see what im doing wrong.
    >
    thanks

    Comment

    • Cowboy \(Gregory A. Beamer\)

      #3
      Re: define global value

      Namespace problem based on the way VB works with folders, at least that is
      my first guess as to why you are having issues.

      Now, the best way to find your problem this is download Reflector (now a
      RedGate tool, but still free):
      See how APIs, libraries, frameworks, and 3rd party .NET code really work with the leading .NET decompiler - .NET Reflector. Runs as a Visual Studio add-in.


      Compile your website (or run a page). Look in the /bin folder using
      reflector. The actual file name for the DLL is folderName.dll, at least in
      general. Open it up and notice declarations for namespaces. You will have to
      delete the directive in the page to get this to compile and see this in
      action, but you will see what is going on.

      Choices
      1. Turn off default VB behavior in options
      2. Add Imports statements to your page
      3. Explicitly add a namespace to your VB functions class file

      --
      Gregory A. Beamer
      MVP, MCP: +I, SE, SD, DBA

      Subscribe to my blog


      or just read it:


      *************** *************** **************
      | Think outside the box! |
      *************** *************** **************
      ".nLL" <noone@here.com wrote in message
      news:3Pcsk.6509 $_M4.4969@newsf e18.ams2...
      hi, im new to asp.net and trying to define a global value. i dont want to
      use web.config because i want to be able to run my app on any sub folder
      without created an application in iis.
      >
      so far i got below in my functons.vb
      >
      ------------------------
      Public Class MyFunctions
      Public Shared Function MyDbPath() As String
      Return "Provider=Micro soft.Jet.OLEDB. 4.0;Data
      Source=|DataDir ectory|bookmark s.mdb;User Id=admin;Passwo rd=;"
      End Function
      >
      >
      Public Shared Function AlphaNumOnly(By Val MyString As String) As String
      Dim sResult As String
      sResult = Trim(MyString)
      If Not sResult = "" Then
      sResult = Regex.Replace(M yString, "[^a-z|A-Z|0-9|\.|\-]{1,50}",
      "")
      End If
      >
      Return sResult
      End Function
      end class
      ----------------------------------------------
      >
      i can use AlphaNumOnly function anywhere within my code and works fine but
      when i try to use myfunctions.MyD bPath() i get error saying ' MyDbPath is
      not member of MYNameSpace.Myf unctions
      >
      I can;t see what im doing wrong.
      >
      thanks

      Comment

      • .nLL

        #4
        Re: define global value

        my solution was


        Public Shared ReadOnly Property MyDbPath() As String
        Get
        Return "Provider=Micro soft.Jet.OLEDB. 4.0;Data
        Source=|DataDir ectory|bookmark s.mdb;User Id=admin;Passwo rd=;"
        End Get
        End Property



        thanks




        ".nLL" <noone@here.com wrote in message
        news:3Pcsk.6509 $_M4.4969@newsf e18.ams2...
        hi, im new to asp.net and trying to define a global value. i dont want to
        use web.config because i want to be able to run my app on any sub folder
        without created an application in iis.
        >
        so far i got below in my functons.vb
        >
        ------------------------
        Public Class MyFunctions
        Public Shared Function MyDbPath() As String
        Return "Provider=Micro soft.Jet.OLEDB. 4.0;Data
        Source=|DataDir ectory|bookmark s.mdb;User Id=admin;Passwo rd=;"
        End Function
        >
        >
        Public Shared Function AlphaNumOnly(By Val MyString As String) As String
        Dim sResult As String
        sResult = Trim(MyString)
        If Not sResult = "" Then
        sResult = Regex.Replace(M yString, "[^a-z|A-Z|0-9|\.|\-]{1,50}",
        "")
        End If
        >
        Return sResult
        End Function
        end class
        ----------------------------------------------
        >
        i can use AlphaNumOnly function anywhere within my code and works fine but
        when i try to use myfunctions.MyD bPath() i get error saying ' MyDbPath is
        not member of MYNameSpace.Myf unctions
        >
        I can;t see what im doing wrong.
        >
        thanks

        Comment

        Working...