Having a problem creating a function to convert processor mhz to ghz. I've done Bytes/MB/GB, but this is just proving a pain in the backside. When I grab my i3 processor speed from WMI, the string reads 2133(mhz) which is plain ugly and would like it to show... (speed in ghz) x (cores), so essentially the string for my Laptop would read '2.13GHz x 4' Can anyone whip me up a conversion function, or am I going to have to figure it out myself ? Thanks in advance, Dave.
Ok, I was being an idiot, this did it... Code: lbhertz.Text = (FormatNumber(Get_Clock_Speed) / 1000 / 1) & "GHz"
Hi incase you haven't already done it.. Does this work for you: Code: Public Function PSpeed() Dim cc As String = "" Dim result As String = "" Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_Processor") For Each Obj As ManagementObject In searcher.Get() cc = Obj("NumberOfCores") Dim speed As Double = CDbl(Obj("CurrentClockSpeed")) Select Case speed Case Is >= 1000 result = String.Format("Processor: {0:0.00} GHz x " & cc, speed / 1000, 1) Case Else result = String.Format("Processor: {0:0.00} MHz x " & cc, speed, 1) End Select Next Return result End Function Usage: Code: CPUS.Text = PSpeed()
As usual, Alphawaves wins the thanks! Yes it works better as my way reports 2.133GHz and once modified yours reports 2.13... One annoying problem, when your object is 'CurrentClockSpeed' from Win32_Processor, if you place this in a Timer to refresh the clock speed it crashes the app on launch. Code: Private Sub ExecutePerc_Tick(sender As System.Object, e As System.EventArgs) Handles ExecutePerc.Tick lbhertz.Text.Refresh lbHertz.Text = PName() End Sub Do I have to invalidate it or something to stop it from crashing?