Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, I just posted this message i

Status
Not open for further replies.

smsinger3

Programmer
Oct 5, 2000
192
US
Hello, I just posted this message in the vb.net group, but after I typed it, I realized it was really meant for here.. Here it goes...

Hello. Does anyone know an eays way to pass variables from a class module to another class module. For instance a logon id, or some other information. Even pass a connection object?

I thought about using "Shared" variables, but this will not work as I am coding in asp.net. "Shared variables" are shared among all sessions and not just an individual user. In other words, if 50 people are logged in, then they get the same values in all 50 sessions. I want each user to have their own values.

I know I can use Session variables, but we are trying to not use those at all for this site. Plus, I don't need to persist any variables every time the forms are submitted.

Thanks for your help! ;-)

Emme
 
Well, if you mean passing data between classes on the one page (not between two different pages), here's an ASP example:
(otherwise I suggest you try to Microsoft: ASP.NET forum)

<%@enablesessionstate=&quot;false&quot; language=&quot;vbscript&quot;%>
<html>
<head>
<title>Object Referencing Object Test</title>
</head>
<body>
<%
'VBscript
class firstclass
private obj_secondclass
public function GetSecondClass(obj_SecondClassReference)
set obj_secondclass = obj_SecondClassReference
end function
public function GetSecondClassMessage()
GetSecondClassMessage = obj_secondclass.messagestring
end function
public function SetSecondClassMessage(str_newmessage)
obj_secondclass.messagestring = str_newmessage
end function
sub Class_Terminate()
set obj_secondclass = nothing
end sub
end class

class secondclass
public messagestring
end class

dim obj_firstclass, obj_secondclass
set obj_firstclass = new firstclass
set obj_secondclass = new secondclass
obj_secondclass.messagestring = &quot;Test text 1&quot;
Response.Write obj_secondclass.messagestring & &quot;<br />&quot;
obj_firstclass.GetSecondClass obj_secondclass
Response.Write obj_firstclass.GetSecondClassMessage & &quot;<br />&quot;
obj_firstclass.SetSecondClassMessage &quot;Test text 2&quot;
Response.Write obj_firstclass.GetSecondClassMessage & &quot;<br />&quot;
Response.Write obj_secondclass.messagestring & &quot;<br />&quot;
set obj_firstclass = nothing
Response.Write obj_secondclass.messagestring & &quot;<br />&quot;
set obj_secondclass = nothing
%> </body>
</html> codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top