We help IT Professionals succeed at work.

split a 1 string into 2 strings

chadmanvb
chadmanvb asked
on
Medium Priority
523 Views
Last Modified: 2013-11-26
I have a string that looks like:

String1= Userid=123 password=1234 CICSID=123 CICSPassword=1234

I would like to create 2 stings that looks like:

String2=  Userid=123 password=1234
String3=  CICSID=123 CICSPassword=1234

I am just not sure how to split this at CICSID-123

Thanks, Chad
Comment
Watch Question

Very easiest method of doing is below, if your string is going to be in same format.

String1= "Userid=123 password=1234 CICSID=123 CICSPassword=1234"

String2= Split(String1, " ")(0) & " "  & Split(String1, " ")(1)
String3= Split(String1, " ")(2) & " "  & Split(String1, " ")(3)

Author

Commented:
Well string1 will change a lot, but one thing that will always be consistant will be "CICSID=".  That is also where I need to split it.  Chad
Now try this, as this will always split at CICSID.


String1= "Userid=123 password=1234 CICSID=123 CICSPassword=1234"

String2 = Mid(String1, 1, Instr(1, String1, "CICSID=")-1)
String3 = Mid(String1, Instr(1, String1, "CICSID="))

Author

Commented:
Thanks, that did it.  Chad

Explore More ContentExplore courses, solutions, and other research materials related to this topic.