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:

Form1 Code:
  1. Imports System
  2. Imports System.Management
  3.  
  4. Public Class Form1
  5.  
  6.     Public CPUInfo As String
  7.     Public CPUSpeed As String
  8.     Public CPUCores As String
  9.  
  10.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  11.  
  12.         ttt.Info()
  13.  
  14.         MsgBox("Info: " & CPUInfo & Environment.NewLine & _
  15.                "Speed: " & CPUSpeed & Environment.NewLine & _
  16.                "Cores: " & CPUCores)
  17.  
  18.  
  19.         Application.Exit()
  20.  
  21.  
  22.     End Sub
  23. End Class
  24.  
  25. Public Class ttt
  26.  
  27.     Public Overloads Shared Function Info() As Integer
  28.  
  29.         Try
  30.             Dim searcher As New ManagementObjectSearcher( _
  31.             "root\CIMV2", "SELECT * FROM Win32_Processor")
  32.  
  33.             For Each queryObj As ManagementObject In searcher.Get()
  34.                 CPUInfo = queryObj("Family")
  35.                 CPUInfo = CPUInfo & " " & queryObj("Manufacturer")
  36.                 CPUCores = queryObj("NumberOfCores")
  37.                 CPUSpeed = queryObj("CurrentClockSpeed") '
  38.             Next
  39.         Catch ex As Exception
  40.  
  41.         End Try
  42.  
  43.     End Function
  44.  
  45. End Class

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