keeping variable info in a code behind / class file

Posted on 2005-04-18
Last Modified: 2010-04-07
I'm using with vb ...

I've got a webform, a code behind page, and a functions.vb page ...

everything works fine, but I want to share variables between functions ...

on my code behind page, i'll call a function in functions.vb, then it will return to the code behind, where i'll call another function from functions.vb ... when i access functions.vb again, i want some variables to be saved ... basically connection variables, that sort of nature ..


Public Class functions
           Dim objConnection as connection

            Function SetConnection()
                   objConnection = whatever
            End Function
            Function 1()
            End Function
                   'I want to be able to access the stored info from objConnection here when I called it the last time
            Function 2()

            End Function
End Class

    on my web form:


end function

function runthisfunction()
       functions.Function2() 'here, i call function2 from the class page, there i want to be able to access objConnection without having to reset the variable ... there's more to this obviously than what i am coding .. but the framework should be the same as in this example ..
end function

Question by:SeanGraflund
    LVL 5

    Accepted Solution

    on your web form you need to do an instance of your class, something like this...

    your webform...
    private oFunc as new functions

    sub btn1_click()
    end sub

    sub runthisfunction()
    end sub
    LVL 1

    Author Comment

    Yup, your right ...

    i was declaring the functions class inside each function ... that would reset the variables :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now