Imports Microsoft.VisualBasic.Devices
Namespace ConsoleApplication2
Class Program
Private Shared Sub Main(args As String())
Dim CI As New ComputerInfo()
'get total memory
Dim availablePhysicalMemory = ((CI.AvailablePhysicalMemory / (1024 * 1024)) * 0.001 + " GB").ToString()
Console.WriteLine("The available physical memory is {0}", availablePhysicalMemory)
Console.ReadKey()
End Sub
End Class
End Namespace
First of all, we need to add the reference to Microsoft.VisualBasic assembly. The property AvailablePhysicalMemory, gets the total amount of free physical memory for the computer. It returns a ULong containing the number of bytes of physical memory for the computer.Now we are first converting the value to Mega bytes(MB) and hence performing CI.TotalPhysicalMemory / (1024 * 1024). Once we obtain the result in Mega bytes(MB), we are converting the same to Giga bytes(GB).We know that
1 MB = 0.001 GB . And hence, is the result.