1

I am trying to split a string simply by the spaces between each word within the string. I then want to put these different parts of the string into separate variables. How do I go about doing this? I have the following:

strOperatingSystem = “Microsoft Windows 7 Professional ”

strVendor = “”
strEdition = “”
strTitle = “”
strVersion = “”

I want the result to be.

strVendor = “Microsoft”
strEdition = “Windows”
strTitle = “Professional”
strVersion = “7”

`

Any help would be appreciated.

1 Answer 1

3

You Split the string at spaces and assign the individual fields of the resulting array to the respective variables.

strOperatingSystem = "Microsoft Windows 7 Professional"

arr = Split(strOperatingSystem)

strVendor  = arr(0)
strEdition = arr(1)
strTitle   = arr(3)
strVersion = arr(2)
Sign up to request clarification or add additional context in comments.

4 Comments

While this might anser the question, please also provide a short explanation on what your code does and how it solves the initial problem.
I assumed something this basic would not require further explanation. Oh, well.
Your answer was flagged for low quality and since we strive for quality content, some explanation and a link to the documentation are always welcome. Additionally, as an experiences SO user, you can be a good role model for new members.
Oh, well, indeed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.