public variable

Results 1 to 2 of 2

Thread: public variable

  1. #1
    Join Date
    Dec 1969

    Default public variable

    I have three methods calc1() calc2() calc3()<BR><BR>I need a variable that can be used across three methods..TOTal variable<BR><BR>how can I do this

  2. #2
    Join Date
    Dec 1969

    Default RE: public variable

    Are these methods in a class? In the server-side script block of an ASP.NET Web page? In either case, you need to make a variable that can be accessed by all of them. If you are using a server-side script block, simply declare the variable outside of the methods, as in:<BR><BR>&#060;script language="VB" runat="server"&#062;<BR><BR> Dim total as Integer = 0<BR><BR> Sub cacl1()<BR> ...<BR> End Sub<BR><BR> ...<BR>&#060;/script&#062;<BR><BR><BR>If you are using a code-behind page, or a class for some sort of library, simply create a member variable for the class.<BR><BR>Public Class Blah<BR> ...<BR> Dim total as Integer = 0<BR><BR> Public Sub Calc1()<BR> ...<BR> End Sub<BR><BR> ...<BR>End Class<BR><BR><BR>hth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts