?
Solved

keeping variable info in a code behind / class file

Posted on 2005-04-18
2
Medium Priority
?
286 Views
Last Modified: 2010-04-07
I'm using asp.net 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 ..

example:

Public Class functions
           Dim objConnection as connection

            Function SetConnection()
                   objConnection = whatever
            End Function
            Function 1()
                   SetConnection()
            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:

btn1_click()
           functions.Function1()

           runthisfunction()
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


thanks!!!
0
Comment
Question by:SeanGraflund
2 Comments
 
LVL 5

Accepted Solution

by:
RogerSTHLM earned 200 total points
ID: 13807919
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()
 ofunc.function1
 runthisfunction()
end sub

sub runthisfunction()
  ofunc.function2()
end sub
0
 
LVL 1

Author Comment

by:SeanGraflund
ID: 13808240
Yup, your right ...

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline
Suggested Courses

807 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