45 pts.
 Remove character from number VBscript
how do i remove from 1.5.600 the .600 part? i just need 1.5 I tried left but it seems only works with strings

Software/Hardware used:
ASKED: July 6, 2011  10:21 PM
UPDATED: March 31, 2012  10:10 PM

Answer Wiki:
OK the actual code: ‘STEP 1 WMI Call ‘************************************************* strComputer = “.” Set objWMIService = GetObject(”winmgmts:” & strComputer & “rootCIMV2″) Set colItems = objWMIService.ExecQuery( _ “SELECT * FROM Win32_OperatingSystem”,,48) For Each objItem in colItems OS = objItem.Version Next OS_Installed = Left(CStr(OS),3)…………….’THIS LINE IS THE ONE THAT SOLVED MY ISSUE, i HAD TO CONVERT “OS” TO A STRING IN ORDER TO USE THE LEFT FUNCTION ‘STEP 2 OS found is XP ‘*************************************************** If OS_Installed = “6.1″ Then WritetoLog “OS is Windows 7 Version Number ” & OS_Installed ‘CONTINUE HERE WITH YOUR OWN LOGIC End If ‘STEP 3 OS found is WINDOWS 7 ‘*************************************************** If OS_Installed = “5.1″ Then WritetoLog “OS is Windows XP Version Number ” & OS_Installed ‘CONTINUE HERE WITH YOUR OWN LOGIC End If
Last Wiki Answer Submitted:  July 8, 2011  5:57 pm  by  Ssergio25   45 pts.
All Answer Wiki Contributors:  Ssergio25   45 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

1.5.600 is a string.

Can you post your code ? Are you getting errors ?

Also, are you going to do this to other values ? if so, are the dots in fixed positions ?

Please provide more details.

 63,535 pts.

 

I too would like to see some of your code thus far, I think I know how to help you but would like to see what you’re doing so far.

 1,940 pts.

 

Sergio, pseudocode will not help trying to find the error. Why don’t you post your actual code ?

If your code is giving errors, in order to help you we need to know:
-Your code
-The exact error messages your are getting.

 63,535 pts.

 

Since we don’t have enough information, this is only a guess:

The value coming from the WMI call is probably not a string, but some type of object.

 63,535 pts.

 

OK the actual code:

‘STEP 1 WMI Call
‘*************************************************
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\” & strComputer & “rootCIMV2″)
Set colItems = objWMIService.ExecQuery( _
“SELECT * FROM Win32_OperatingSystem”,,48)
For Each objItem in colItems
OS = objItem.Version
Next

OS_Installed = Left(CStr(OS),3)…………….’THIS LINE IS THE ONE THAT SOLVED MY ISSUE, i HAD TO CONVERT “OS” TO A STRING IN ORDER TO USE THE LEFT FUNCTION

‘STEP 2 OS found is XP
‘***************************************************

If OS_Installed = “6.1″ Then
WritetoLog “OS is Windows 7 Version Number ” & OS_Installed
‘CONTINUE HERE WITH YOUR OWN LOGIC
End If

‘STEP 3 OS found is WINDOWS 7
‘***************************************************

If OS_Installed = “5.1″ Then
WritetoLog “OS is Windows XP Version Number ” & OS_Installed
‘CONTINUE HERE WITH YOUR OWN LOGIC
End If

 45 pts.

 

It seems that you have solved the issue.

Thanks for sharing your solution.

 63,535 pts.