How do I make a variable available to another form
I am trying to use a variable from one user control on another. Can anyone help
How do I make a variable available to another form
I am trying to use a variable from one user control on another. Can anyone help
How do I make a variable available to another form?
LotusExigeS1
One option is to stored your variable in the session cache.
' This method does not require navigation between the two pages
' and will persist the object in the cache until removed
' add an item to the session cache on page one
Dim myObj As Integer
Session.Add("myItem", myObj)
' retrieve on a different page
Dim retrievedObj As Integer
retrievedObj = Session.Item("myItem")
If Not Nothing = retrievedObj Then
' do page logic based on available variable
' remove from cache
Session.Remove("myItem")
End If
histonftm
Edit 1: I forgot this was Visual Basic. You can access settings by going to My.Settings
X-Tatic
declare the variable global (in a module) you can access it every where.
or else you can make the variable in the form as public and access it in another form as <form name>.<variable name>
or else creating property you can access all the variable in the form.
mspinder
perhaps this post will guide you better
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=700751&SiteID=1
Another way I guess would be to make a class/module static so you can set variable as required and let other forms access it without passing references. There are a couple of ways to go about it but hope the above link will help you at least
Sammy2006
J Tatta
As per the example provided if you are actually using an type of integer you would actually check for non zero value as the integer will be initilaised as zero.
If
retrievedObj > 0 Then End IfBillyB
I've woke up now! Sorry about that one!
MarkBosley