[RESOLVED] [2008] Problem sending stuff to Varibles from WMI
Good Morning,
This is a bit of a strange one that probally has a really simple answer that almost everyone knows but because I am a begginer I don't know what I am doing. I would bug my collegue with this one as he is the vb.net king here :-p but he is currently in a meeting so was wondering if someone here can help me.
I am making it as a service but for testings purposes I just copy bits into a Windows Application just to make sure that bit of code works ok. I have got one form and thats it in this test project and this is the code I have in there:
I have the code in a function to get the info from WMI and put it into Varibles then back in the main sub I just have a simple msgbox to display the values in just to make sure its working.
When I run the code the message box displays but with no data from the WMI just blank. I have done some troubleshooting and break points and If i put a break point in the function just after the loop and then in the Immediate window I ask for the values of the Varibles and it returns what I am expecting to see however if I put the break point on the first message box and find out what the varibles are they equal Nothing.
From the Function to the Form Load Event where is it loosing the data. Its probally really simple and something I have done wrong but I just don't understand what.
Thanks,
Max
Re: [2008] Problem sending stuff to Varibles from WMI
I have just done an experiment and declared the varibles in a module rather than within the form and the code all works fine now. Can someone try and explain this to me, why has it done it like this?
Thanks,
Max
Re: [2008] Problem sending stuff to Varibles from WMI
It looks like CPUInfo, CPUSpeed and CPUcores are class level variables in Form1 however you are trying to reference them in class ttt as a shortname, so that equates to ttt.CPUInfo etc...
Try fully qualifying the names in TTT as Form1.CPUInfo, Form1.CPUSpeed and Form1.CPUCores
I think if you have Option Explicit on, it would of flagged those as undefined and thrown an error at design time.
EDIT: damn wanted to post it before you did ;)
Re: [2008] Problem sending stuff to Varibles from WMI
HaHa well thanks anyway I understand what Your saying I worked out how to fix it but I didn't understand why it was happening which you have cleared up for me. I didn't even think about that so thanks :-)