Question How to put WMI code in TextBox

bellil

Member
Joined
Sep 19, 2011
Messages
10
Programming Experience
1-3
first of all i want thank the admins here for this nice and helpfully forms.

second:
I am looking to put the end value of this code below in the TextBox.


VB.NET:
Imports System
Imports System.Management
Imports System.Windows.Forms

Namespace WMISample

    Public Class MyWMIQuery

        Public Overloads Shared Function Main() As Integer

            Try
                Dim searcher As New ManagementObjectSearcher( _
                    "root\CIMV2", _
                    "SELECT * FROM Win32_CDROMDrive") 

                For Each queryObj As ManagementObject in searcher.Get()

                    Console.WriteLine("-----------------------------------")
                    Console.WriteLine("Win32_CDROMDrive instance")
                    Console.WriteLine("-----------------------------------")
                    Console.WriteLine("SerialNumber: {0}", queryObj("SerialNumber"))
                Next
            Catch err As ManagementException
                MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
            End Try
        End Function
    End Class
End Namespace

end value i'm looking for it's : Serial Number.

 
hi it would be simler to:

TextBox1.text = "SerialNumber: " & queryObj("SerialNumber")
'If your adding all CDDrives then it would be the same line with a added "+" before the equals like so
TextBox1.text += "SerialNumber: " & queryObj("SerialNumber")

this should work. :)
 
Back
Top