Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display two functions in one message box 4

Status
Not open for further replies.

ladyemrys

Programmer
Aug 17, 2007
44
US
Hi!

I've been asked to modify this code to have both functions displayed in one message box, but my VB is very poor. Any help would be much appreciated, thank you in advance. The code is below:

strComputer = "."

' Function ShowBIOSInfo()
On Error Resume Next
DisplayOutputHeader("BIOS - Win32_BIOS")
str = ""
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")
For each objBIOS in colBIOS
str = str & GetTableHeader()
str = str & GetRow("Build Number", objBIOS.BuildNumber)
str = str & GetRow("Current Language", objBIOS.CurrentLanguage)
str = str & GetRow("Installable Languages", objBIOS.InstallableLanguages)
str = str & GetRow("Manufacturer", objBIOS.Manufacturer)
str = str & GetRow("Name", objBIOS.Name)
str = str & GetRow("Primary BIOS", objBIOS.PrimaryBIOS)
str = str & GetRow("Release Date", objBIOS.ReleaseDate)
str = str & GetRow("Serial Number", objBIOS.SerialNumber)
str = str & GetRow("SMBIOS Version", objBIOS.SMBIOSBIOSVersion)
str = str & GetRow("SMBIOS Major Version", objBIOS.SMBIOSMajorVersion)
str = str & GetRow("SMBIOS Minor Version", objBIOS.SMBIOSMinorVersion)
str = str & GetRow("SMBIOS Present", objBIOS.SMBIOSPresent)
str = str & GetRow("Status", objBIOS.Status)
str = str & GetRow("Version", objBIOS.Version)

'
' Wscript.Echo "Serial Number" & objBIOS.SerialNumber & Chr(13)

Wscript.Echo "New HP WINDOWS XP SP2 Image Ver 2008" & Chr(13) & _
"Computer Manufacturer n Model: " & objBIOS.Version & Chr(13) & _
"Computer Serial Number: " & objBIOS.Serialnumber & Chr(13) & chr(13)

str = str & GetTableFooter()

Next

' End Function


Function ShowSystemInformation()
On Error Resume Next
DisplayOutputHeader("System information")
str = ""

Set objWMIService = GetWMIServices()
Set colSettings = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
str = str & "<H2>Operating systems</H2>" & vbCRLF
For Each objOperatingSystem in colSettings
str = str & GetTableHeader()
str = str & GetRow("OS Name", objOperatingSystem.Name)
str = str & GetRow("Version", objOperatingSystem.Version)
str = str & GetRow("Service Pack", _
objOperatingSystem.ServicePackMajorVersion & "." & objOperatingSystem.ServicePackMinorVersion)
str = str & GetRow("OS Manufacturer", objOperatingSystem.Manufacturer)
str = str & GetRow("Windows Directory", objOperatingSystem.WindowsDirectory)
str = str & GetRow("Locale", objOperatingSystem.Locale)
str = str & GetRow("Available Physical Memory", objOperatingSystem.FreePhysicalMemory)
str = str & GetRow("Total Virtual Memory", objOperatingSystem.TotalVirtualMemorySize)
str = str & GetRow("Available Virtual Memory", objOperatingSystem.FreeVirtualMemory)
str = str & GetRow("OS Name", objOperatingSystem.SizeStoredInPagingFiles)
str = str & GetTableFooter()
Next

Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
str = str & "<H2>Computer systems</H2>" & vbCRLF
For Each objComputer in colSettings
str = str & GetTableHeader()
str = str & GetRow("System Name", objComputer.Name)
str = str & GetRow("System Manufacturer", objComputer.Manufacturer)
str = str & GetRow("System Model", objComputer.Model)
str = str & GetRow("Time Zone", objComputer.CurrentTimeZone)
str = str & GetRow("Total Physical Memory", objComputer.TotalPhysicalMemory)
str = str & GetTableFooter()
Next

Set colSettings = objWMIService.ExecQuery("Select * from Win32_Processor")
str = str & "<H2>Processors</H2>" & vbCRLF
For Each objProcessor in colSettings
str = str & GetTableHeader()
str = str & GetRow("System Type", objProcessor.Architecture)
str = str & GetRow("Processor", objProcessor.Description)
str = str & GetTableFooter()
Next

Set colSettings = objWMIService.ExecQuery("Select * from Win32_BIOS")
str = str & "<H2>BIOS</H2>" & vbCRLF
For Each objBIOS in colSettings
str = str & GetTableHeader()
str = str & GetRow("BIOS Version", objBIOS.Version)
str = str & GetTableFooter()
Next

Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration")
str = str & "<H2>Display configuration</H2>" & vbCRLF
For Each objItem in colItems
str = str & GetTableHeader()
str = str & GetRow("Bits Per Pel", objItem.BitsPerPel)
str = str & GetRow("Device Name", objItem.DeviceName)
str = str & GetRow("Display Flags", objItem.DisplayFlags)
str = str & GetRow("Display Frequency", objItem.DisplayFrequency)
str = str & GetRow("Driver Version", objItem.DriverVersion)
str = str & GetRow("Log Pixels", objItem.LogPixels)
str = str & GetRow("Pels Height", objItem.PelsHeight)
str = str & GetRow("Pels Width", objItem.PelsWidth)
str = str & GetRow("Setting ID", objItem.SettingID)
str = str & GetRow("Specification Version", objItem.SpecificationVersion)
str = str & GetTableFooter()
Next

DisplayOutput(str)
End Function

On Error Resume Next
IP = ""
Set WMI = GetObject("WinMgmts://")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set wmiWin32Comp = WMI.InstancesOf("Win32_NetworkAdapterConfiguration")
for each NetInfo in wmiWin32Comp
if NetInfo.IPEnabled then
For Each IPElement in NetInfo.IPAddress
IP = IP & IPElement & ", "
Next
end if

next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For Each objItem in colItems
For Each strOption in objItem.ConfigOptions

Next



' WScript.Echo "Ip address = " & IP
' Wscript.Echo "Serial Number: " & objItem.SerialNumber
' VBScript.
'

Next


WScript.Echo "Domain = " & WshNetwork.UserDomain & Chr(13) & _
"Computer Name = " & WshNetwork.ComputerName & Chr(13) & _
"User Name = " & WshNetwork.UserName & chr(13) & _
"Ip address = " & IP & chr(13)
 



Hi,
Code:
msgbox function1() & ":" & function2()


Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
Thanks Skip! Alas, it didn't work with this script! I tried to comment out where his script makes the message boxes pop up to no avail. Nothing at all came out when i did it.

This is what i added:

msgbox ShowBIOSInfo() & ":" & ShowSystemInformation()

I also tried with just function1() and function2() which didn't work either.
 

You don't get anything out of;

MsgBox ShowBIOSInfo() & ":" & ShowSystemInformation()

because you do not assign anything to (variants) ShowBIOSInfo or ShowSystemInformation.

Try to add the blue line of code:
Code:
 Function ShowBIOSInfo()

[...]

Wscript.Echo "New HP WINDOWS XP SP2 Image Ver 2008" & Chr(13) & _
             "Computer Manufacturer n Model: " & objBIOS.Version & Chr(13) & _ 
             "Computer Serial Number: " & objBIOS.Serialnumber & Chr(13) & chr(13) 

        str = str & GetTableFooter()

    Next

   [blue]ShowBIOSInfo = str[/blue]

'  End Function
and the same for ShowSystemInformation


Have fun.

---- Andy
 
It looks to me like the existing functions are building an HTML table, which wouldn't be much use if you want the results shown in a messagebox.

Also, the functions don't seem to return anything, they just pass on the built-up string to another function.

You are going to have to rewrite those functions to:
1. Remove the HTML markup
2. Return their values (e.g. ShowSystemInformation = str)

The new functions should be simpler, as you don't need to worry about the HTML markup. For example, this
Code:
str = str & GetRow("Manufacturer", objBIOS.Manufacturer)
would become something like
Code:
str = str & Chr(13) & Chr(10) "Manufacturer = " & objBIOS.Manufacturer


 
<Chr(13) & Chr(10)
This string may be replaced with the constant vbCrLf, too.
 

And vbCrLf may be replaced with the constant vbNewLine, too. :)


Have fun.

---- Andy
 
Reading between the lines, I'm betting this is VBScript, in which case both vbCrLf or vbNewLine will only add to the OP's confusion.

I played it safe with the Chr functions.

 
Thanks to everyone for their suggestions! I will click on the Thanks links too once i get it working!!! I'll check back in to let you all know how it worked!!! Thanks again.
 
Yes, that's so. I was going with the idea that the OP was "translating" into VB.
 
It's actually a VB script that was copied in part from other scripts by one of our techs. I took a short VB class at SMC but didn't learn a whole lot from it LOL! I'm much more familiar with C#/++ than VB. I havent' yet had a chance to try everything suggested so maybe from home tonight I'll test them all out to see if i can get them to work!

Thanks again to everyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top