Display Bios Information in VB.NET

Today, I will teach you how to create a program that can display the hardware information of the BIOS using VB.NET. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add a TabControl and a DataGridView Only. You must design your interface like this: output 3. Now, we will do the coding. First we will create a vb module named globals. We will have to create public sub procedure named addRow that will add rows to the DataGridView.
  1.     Public Sub addRow(ByRef dt As DataTable, ByVal p As String, ByVal v As String)
  2.         Dim dr As DataRow
  3.         dr = dt.NewRow
  4.         dr("Property") = p
  5.         dr("Value") = v
  6.         dt.Rows.Add(dr)
  7.     End Sub
And will add the column names using a function named getStructure()
  1.     Public Function getStructure() As DataTable
  2.         Dim dt As New DataTable
  3.         dt.Columns.Add(New DataColumn("Property"))
  4.         dt.Columns.Add(New DataColumn("Value"))
  5.         Return dt
  6.     End Function
4. Then now, we will code for our Form_Load, put this code below: Import first the System.Management library.
  1. Imports System.Management
And with this in the Form_Load.
  1.  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Try
  3.  
  4.             Dim searcher As New ManagementObjectSearcher( _
  5.                       "root\CIMV2", _
  6.                       "SELECT * FROM Win32_BIOS")
  7.             Dim dt As DataTable = globals.getStructure
  8.             For Each queryObj As ManagementObject In searcher.Get()
  9.                 If queryObj("BIOSVersion") Is Nothing Then
  10.                     globals.addRow(dt, "BIOSVersion", queryObj("BIOSVersion"))
  11.                 Else
  12.                     Dim arrBIOSVersion As String()
  13.                     arrBIOSVersion = queryObj("BIOSVersion")
  14.                     For Each arrValue As String In arrBIOSVersion
  15.                         globals.addRow(dt, "BIOSVersion", arrValue)
  16.                     Next
  17.                 End If
  18.                 globals.addRow(dt, "CurrentLanguage", queryObj("CurrentLanguage"))
  19.                 globals.addRow(dt, "Description", queryObj("Description"))
  20.                 globals.addRow(dt, "Manufacturer", queryObj("Manufacturer"))
  21.                 globals.addRow(dt, "PrimaryBIOS", queryObj("PrimaryBIOS"))
  22.                 globals.addRow(dt, "ReleaseDate", queryObj("ReleaseDate"))
  23.             Next
  24.             Me.DataGridView1.DataSource = dt
  25.  
  26.         Catch err As ManagementException
  27.             MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
  28.         End Try
  29.            
  30.     End Sub

Output:

output Download the source code and try it. For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment