Remove character from number VBscript

45 pts.
Tags:
VBScript
Visual Basic
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    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.
    69,920 pointsBadges:
    report
  • TheFinder
    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 pointsBadges:
    report
  • carlosdl
    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.
    69,920 pointsBadges:
    report
  • carlosdl
    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.
    69,920 pointsBadges:
    report
  • Ssergio25
    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 pointsBadges:
    report
  • carlosdl
    It seems that you have solved the issue. Thanks for sharing your solution.
    69,920 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following