Displaying Computer information using Visual Basic.Net
Submitted by joken on Friday, September 20, 2013 - 18:28.
This article shall describe how to display computer information, and processes of current running program or application on a machine. It also detects if the machine is connected to the network or not. You can see also the current usage of of a computer physical memory, virtual memory, Operating system used, Operating system platform, Version, Monitor Heigh and Monitor Width.
After completing this application, it looks like as shown below:
To start building this program, open visual basic in your machine and create a new project. Then add a datagridview, a groupbox, a progressbar, twelve label and eleven textbox and a timer. Then customize and arrange all the controls same with the arrangement seen above and rename all the label same as shown in the final design.
Then double click the timer1, and add the following code:
Next, double click the main form and add the following code:
And you can now test your program by pressing “F5”.

- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- 'this three lines of code is responsible for providing data about memory
- Dim availphyMem As Integer = My.Computer.Info.AvailablePhysicalMemory / 1000000
- Dim totlPhyMem As Integer = My.Computer.Info.TotalPhysicalMemory / 1000000
- Dim totVirtMem As Integer = My.Computer.Info.TotalVirtualMemory / 1000000
- 'this line is for the name of computer
- Dim compname As String = My.Computer.Name
- 'current username used on the machine
- Dim compuser As String = SystemInformation.UserName
- 'display the Operating installedon this machine
- Dim OS As String = My.Computer.Info.OSFullName
- 'show the platform of the operating installed
- Dim OSplatform As String = My.Computer.Info.OSPlatform
- 'it display the Operating system version
- Dim osversion As String = My.Computer.Info.OSVersion
- 'display the height and width of the machine
- Dim HeighMon As Integer = SystemInformation.PrimaryMonitorSize.Height
- Dim WidthMon As Integer = SystemInformation.PrimaryMonitorSize.Width
- 'it loops trough all the processes happening running in this machine
- For Each p As Process In Process.GetProcesses
- 'it display to the datagridview provided
- DT.Rows.Add(p.ProcessName.ToString)
- Next
- 'it check if the machine is connectd to the network or not
- If My.Computer.Network.IsAvailable Then
- txtnetavailable.Text = "Connected"
- Else
- txtnetavailable.Text = "Not Connected"
- End If
- 'it get and set the maximum value of progressbar
- ProgressBar1.Maximum = availphyMem
- ProgressBar1.Value = availphyMem
- 'this is the formula to get the percentage
- percent = (ProgressBar1.Value / totlPhyMem) * 100
- 'it display the percentage in the label
- lblpercent.Text = percent & "%"
- 'it assign and display all the data from the variable above
- 'and display the corresponding value into the textboxes provided
- txtcompname.Text = compname
- txtusername.Text = compuser
- txtos.Text = OS
- txtosplatform.Text = OSplatform
- txtosversion.Text = osversion
- txtavailmem.Text = availphyMem & " MB"
- txtphymem.Text = totlPhyMem & " MB"
- txtvirmem.Text = totVirtMem & " MB"
- ProgressBar1.Maximum = totlPhyMem
- txtheigh.Text = HeighMon
- txtwidth.Text = WidthMon
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'it starts the timer
- Timer1.Start()
- 'create new column named "List of processes"
- DT.Columns.Add("List of Processes")
- 'set the datasource of the datagridview to DT
- DataGridView1.DataSource = DT
- End Sub
- </vbent>
- And below Public class, add the following code:
- <vbnet>
- 'declaration of variable
- Dim processName As String
- 'declaration of DT variable as Datatable
- Dim DT As New DataTable
- Dim percent As Integer
Add new comment
- 778 views