Global Declares in VB .NET

  • Thread starter Thread starter Beebs
  • Start date Start date
B

Beebs

I need to put a conditional around some global, or public delclares in
my main module, but that obviously doesn't work. What other options
do I have to do this. My three variables are:

Dim MyReader As New Symbol.Barcode.Reader
Dim MyReaderData As New
Symbol.Barcode.ReaderData(Symbol.Barcode.ReaderDataTypes.Text,
Symbol.Barcode.ReaderDataLengths.DefaultText)
Dim MyReaderHandler As New System.EventHandler(AddressOf
MyReader_Notify)

and they need to be accessible for the whole application if the device
is a certain type, which I'm able to check for in my Main()

Thanks
 
It means that you have not explained your scenario very well *and* you
assume all posts get replies within 13 hours.

What do you mean conditional? For compile time conditionals use #if

What do you mean "declares"? VB supports the Declare keyword but you can
also use DllImport.

For global access to variables make them Shared e.g.

Public Class MyGlobals
Public Shared MyReader As New Symbol.Barcode.Reader
End Class

Call it like this:
MyGlobals.MyReader.XXX

If you provide more info on your question we can help further...

Cheers
Daniel
 

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

Similar Threads

Scanner Uses Memory 4
Shared Method Error 3
Global variable declaration! 3
global variable 3
VB Scalar Declaration Error 6
Global/Public 2
Showing global variable in a report?? 1
Declaring Global Variables 1

Back
Top