Jump to content

add class variable


Nim199

Recommended Posts

Hi,How, with VB.NET, can I define a variable inside a sub, that can be used throught the class?

Link to comment
Share on other sites

If VB is anything like C#, then you can't. You'd have to declare the variable outsite the method ("sub") and then instantiate it inside the method ("sub").C#

private string message;public void DoSomething(){	message = "Some text";}public void DoSomethingElse(){	Response.Write(message);}

Link to comment
Share on other sites

@jesh that is correct but you are still inside the class

public class MyClass {  private string message;  public MyClass {  }  public void DoSomething()  {	  message = "Some text";  }  public void DoSomethingElse()  {	  Response.Write(message);  }}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...