How to declare a public variable in methods in VB.NET

M

Mamatha

Hi

If any one knows,please tell me how can we declare a
public variable in methods of VB.NET like

public indx as integer.

How can i use that variable in another methods like global
variable.

Mamatha
 
R

Robby

Procedures can not define Public variables only Private (aka Dim) and Shared
variables. If you want all procedures in your Module or Class to have
access to a variable then delare it at the Module or Class level
respectively. If delcared Private all your procedures will be able to
access the variable but prodecures outside the Module or Class will not be
able to access it directly.

--Ride
 
H

Herfried K. Wagner [MVP]

Robby said:
Procedures can not define Public variables only Private
(aka Dim) and Shared variables.

Procedures cannot define 'Privazte' or 'Shared' variables. They can define
local or local static variables.

What you can do inside a procedure is redimensioning a private/public array
variable declared in the class using 'ReDim'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top