Advertisement

12.21.2007 at 10:07AM PST, ID: 23038716
[x]
Attachment Details

Function to view memory sizes of a system

Asked by troehm in Visual Basic Programming, Miscellaneous Programming, VB Script

Tags: Microsoft, Visual Basic, VBscript, 6

Hi Guys,

I'm using this in VB6, i'm not too familiar with some of the things in VBScript. But basically this will print on a form the size of each memory module in the system and the total maximum amount of memory that can be put in the machine (correct me if i'm wrong). So say I have a machine with 2x256mb. I need it to spit out DIMM 1: 256Mb, DIMM2: 256Mb, Maximum Capacity 1GB. But, inorder to do that I need a way to distinguish each objItem it finds. I could probably do it if I knew how many instances of objItem.Capacity it has before it enters the loop. See what I'm saying, sorry I know I might not make too much sense.

So right now, the program will spit out
268435456mb
268435456mb
1048576mb

In a nutshell I don't know how to go about modifying the code so it will detect the last instance of 1048576mb and add a label of Maximum Capacity and then add the first 2 together by the time it gets out of the loop.

Thanks for any help provided.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Public Sub PhysicalMemory(pc As String)
 
On Error Resume Next
 
Set objWMIService = GetObject("winmgmts:\\" & pc & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory", , 48)
 
For Each objItem In colItems
    info.Print objItem.Capacity & "mb"
Next
 
End Sub
 
Loading Advertisement...
 
[+][-]12.21.2007 at 10:21AM PST, ID: 20515385

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.21.2007 at 10:32AM PST, ID: 20515436

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Basic Programming, Miscellaneous Programming, VB Script
Tags: Microsoft, Visual Basic, VBscript, 6
Sign Up Now!
Solution Provided By: jared_luker
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628