user1439018
user1439018

Reputation: 1

Declaration of Variables in Vb 2010

I am creating a kind of a "naive" search engine.

What I have done is distributed words in files where each file corresponds to the starting letter of the words (i.e. if its English, then 26 files are there)

Then when the search system loads I am loading all the words in hash tables (26 hash tables corresponding to 26 alpha-characters) for which I am using an array of structures.

The problem is after declaring the variables in a Form load subroutine, the variables are not able to use those values in other subroutines....

How do I properly declare them so their values persist?

Upvotes: 0

Views: 288

Answers (1)

Sarfraz
Sarfraz

Reputation: 382851

Declare them above all routines but inside the main Class then they will be available elsewhere too. For example:

Public Class yourClassName
   ' declare your variables here

When you declare variables inside a subroutine, they will be available only inside that subroutine, that's why you need to declare them at class-level for them to be available in other subroutines too.

Fore more info, see the docs (Thanks to @Drise)

http://msdn.microsoft.com/en-us/library/1t0wsc67.aspx

Upvotes: 4

Related Questions