Re: Global Variable in Class
- From: Joshua Flanagan <josh@xxxxxxxxxx>
- Date: Fri, 08 Apr 2005 20:40:08 -0500
Now I'm confused. Do you want the variable to be in the function (no data is saved across function calls), or do you want the variable outside of the function (dad is saved across function calls)?
If you want the variable inside the function, just declare it in the function:
Public Class dataClass
Public Shared Function GetRep(ByVal prodNumber As Integer) As DataSet
Dim ProdName as String
'do stuff with ProdName - value is lost at end of function
End Function
End ClassIf you want the variable outside the function, just declare it outside of the function (but make sure to add the Shared modifier so it is available to Shared functions):
Public Class dataClass Private Shared ProdName as String Public Shared Function GetRep(ByVal prodNumber As Integer) As DataSet 'do stuff with ProdName ' value is still available after function End Function End Class
Joe via DotNetMonster.com wrote:
Thanks for the reply. I have declared the function as shared. How would I define the variable within the function?
.
- References:
- Global Variable in Class
- From: Joe via DotNetMonster.com
- Re: Global Variable in Class
- From: Joshua Flanagan
- Re: Global Variable in Class
- From: Joe via DotNetMonster.com
- Global Variable in Class
- Prev by Date: Re: Passing user credintials from a web page to a web service.
- Next by Date: Re: Can I make links in a datagrid?
- Previous by thread: Re: Global Variable in Class
- Next by thread: running sql script
- Index(es):
Relevant Pages
|