Nim199 Posted November 8, 2007 Share Posted November 8, 2007 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 More sharing options...
jesh Posted November 9, 2007 Share Posted November 9, 2007 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 More sharing options...
aspnetguy Posted November 12, 2007 Share Posted November 12, 2007 @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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.