How to Create a Simple CPU and RAM Meter in Visual Basic 2008

In this tutorial I will teach you how to create a simple CPU and RAM meter by using Visual Basic 2008. With this, you will be able to know the usage of your RAM and CPU. And it also calculates the percentage of its performance usage. Let’s begin: Open Visual Basic 2008, create a new Windows Application and drag the Label, ProgressBar, PerformanceCounter and a Timer. Name the two PerformanceCounters, “pcCPU” and the other one is “pcRAM”. Then, name the two Labels into “lblCPU” and “lblRAM”. Then, name the two ProgressBars into “pbCPU”and “pbRAM”. first form After that, click the “pcCPU” PerformanceCounter and go to the properties, then select “Processor” for the Category Name ,“% Processor Time” for the Counter Name and "_Total" for the Instance Name. CPU Then, click the other PerformanceCounter named “pcRAM” and go to the properties again, then select “Memory” for Category Name and “ % Commited Bytes in Use” for the Counter Name. RAM Double click the Timer and do the following code in the method.
  1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2. 'SET THE PERFORMANCE VALUE TO A PROGESSBAR
  3. pbCPU.Value = pcCPU.NextValue
  4. pgRAM.Value = pcRAM.NextValue
  5. 'SET THE PROGRESS BAR VALUE TO THE LABEL TO KNOW WHAT IS THE PERCENTAGE OF THE PROCESS.
  6. lblcpu.Text = pbCPU.Value & "%"
  7. lblram.Text = pgRAM.Value & "%"
  8. End Sub
Go back to the Design Views, double click the Form and do the following code for starting the timer on the first load.
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2. 'SET THE INTERVAL TO 500.
  3. Timer1.Interval = 500
  4. 'START THE TIMER
  5. Timer1.Start()
  6.  
  7. End Sub
Output : output

Comments

Submitted byjankoon Sat, 01/24/2015 - 06:32

error !!! “ % Commited Bytes in Use” ______ma być ( “ % Committed Bytes in Use”) Then, name the two ProgressBars into “pbCPU”and “pbRAM”._______ma być ( “pgRAM ”)

Add new comment