How to Create CPU and RAM Meter in VB.NET
This tutorial is all about How to Create CPU and RAM Meter in VB.NET.
In this tutorial, I will teach you how to create a CPU and RAM meter in VB.NET. With this, you will be able to determine the usage and it calculates the percentage of the RAM and CPU in your computer.
What is Visual Basic’s purpose?
The third-generation programming language was created to aid developers in the creation of Windows applications. It has a programming environment that allows programmers to write code in.exe or executable files. They can also utilize it to create in-house front-end solutions for interacting with huge databases. Because the language allows for continuing changes, you can keep coding and revising your work as needed.
However, there are some limits to the Microsoft Visual Basic download. If you want to make applications that take a long time to process, this software isn’t for you. That implies you won’t be able to use VB to create games or large apps because the system’s graphic interface requires a lot of memory and space. Furthermore, the language is limited to Microsoft and does not support other operating systems.
What are the most important characteristics of Visual Basic?
Microsoft Visual Basic for Applications Download, unlike other programming languages, allows for speedier app creation. It has string processing capabilities and is compatible with C++, MFC, and F#. Multi-targeting and the Windows Presentation Framework are also supported by the system, allowing developers to create a variety of Windows apps, desktop tools, metro-style programs, and hardware drivers.
Open Visual Basic, create a new Windows Form Application and drag the Label, ProgressBar, PerformanceCounter and a Timer. Name the two PerformanceCounters, “pc_CPU” and the other one is “pc_RAM”. Name the two Labels into “lbl_CPU” and “lbl_RAM”. Then, name the two ProgressBars into “pb_CPU”and “pb_RAM”.
After setting up the Form, click the “pc_CPU” PerformanceCounter and go to the properties. In properties of “pc_CPU”, select “Processor” for the Category Name,“% Processor Time” for the Counter Name and “_Total” for the Instance Name.
After setting up the properties of the “pc_CPU”, click the other PerformanceCounter named “pc_RAM” and go to the properties. In the properties, select “Memory” for Category Name and “ % Commited Bytes in Use” for the Counter Name.
Now, double click a Timer to fire the “Tick” event handler. In the “Tick” event handler, you have to setup the performance and the percentage of the CPU and RAM of the computer.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
‘SET THE PERFORMANCE VALUE OF THE RAM AND CPU TO THE PROGESSBAR
pb_CPU.Value = pc_CPU.NextValue
pb_RAM.Value = pc_RAM.NextValue
‘SET THE PROGRESS BAR VALUE TO THE LABEL TO KNOW WHAT IS THE PERCENTAGE OF THE PROCESS.
lbl_cpu.Text = pb_CPU.Value & “%”
lbl_ram.Text = pb_RAM.Value & “%”
Go back to the Design Views and double click the Form. In the
Form1_Load, you have to start the timer and setup the interval of it.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
‘INITIALIZE THE INTERVAL OF THE TIMER TO 500.
Timer1.Interval = 500
‘START THE TIMER
You can download the Complete Source Code.
Readers might read also: