Wireless Communication Library Support Forum
Frameworks => Bluetooth Framework => Topic started by: roadhouse on February 15, 2010, 09:04:10 PM
-
Sorry if this is a stupid question but I'm returning to programming after many many years and still gettin to grips with OOP.
In VB2008, I can get the demo files to run no problem. But if i try to write my own code based on the demos I get constant erros about 'reference to a non-shared member requires an object reference' and messages about 'handles' not being defined in a variable first when using event handlers. I can get round this by declaring a variable first then using that but I would realy like to know if i am doing something fundamentally wrong here. For example,
In the proximitydemo the library is refreneced like this...
Private Sub fmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wclAPI.Load()
End Sub
but in my programs I have to use...
Private Sub fmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim x As wcl.wclAPI = New wcl.wclAPI
x.Load()
End Sub
Which then works.
Dont worry, I'm not looking for a VB primer, i appreciate thats not what you are here for. But I am so confused about why it works one way with the demo code and not when I try to write the same code in my own programs ? As a beginner, its causing me some considerable confusion when having to dimension variables all over the place. Your demo code looks much easier to follow.
Is there something else I have to do to my VB environment to get it to work like the demo ? a reference or a system setting or something else ?
Cheers
-
Hi,
Because X is local variable. When routine is done (exited) variable is destroyed. Declare it as global or drop component on the form.
-
Thanks Mike,
So I can drop the 'WCL' component directly onto the form ? thats pretty cool.
If i can be cheeky and ask one more question, how do I do that ? I can load the WCL library as a reference but it doesnt appear in the component toolbox.
Sorry for the newbie questions, but I'm desperatley trying to find my way round this stuff and the internet resources for people like me are so thin on the ground. Most assume you know all this stuff and go directly into talking technical.
In my job i'm a Cisco Design Architect (CCNA,CCDA,CCDP) I'm not techically inept, just not a programmer.
Be gentle and Thanks for your help.
Cheers
-
Hi,
Right click on toolbox -> Add toolbox item->Select wcl.dll and its components.
All those things are very good described in Visual Studio Help system
-
Hi Mike,
Thanks for the advice. I have it working now. Although it would not let me drag and drop the wclAPI component onto the form directly, I was able to get round it using Me. declarations instead.
Thaks again.
Cheers