-
I want to be able to separate a string into two further strings - probably easiest by finding the first 'space' in the string.
Eg. the string contains a website and a description. I need to be able to split them into two strings:
http://www.yahoo.co.uk UK version of this popular search engine http://www.bbc.co.uk The BBC's own Internet home page http://www.knowsley.gov.uk Knowsley MBC's home on the 'Net
Hope someone can help :)
Simon
-
you can always used the Instr command like
Dim Pos%, MyStr1$, MyStr2$
Pos% = Instr(1,"http://www.bbc.co.uk <Description>"," ", vbBinaryCompare)
if Pos% <> 0 then
MyStr1$ = left("http://www.bbc.co.uk <Description>", Pos%-1)
MyStr2$ = Mid("http://www.bbc.co.uk <Description>",pos%+1)
End IF
____________________
Chris.C :cool:
[b]Software Engineer[/]
[email protected]
-
Use the InStr function to determine the location of the space. InStr finds the first occurence of a specified character in a string.
Private Sub Command1_Click()
Dim String1, String2, String3 As String
String1 = "http://www.yahoo.co.uk UK version of this popular search engine"
String2 = _
Left(String1, InStr(String1, " "))
String3 = _
Right(String1, Len(String1) - InStr(String1, " "))
End Sub
------------------
Andrew Nerney
Hapless Programmer
[email protected]
-
-
No hay problema, simonp! And ChrisC - looks like great minds think alike. Same function and posted the exact same minute! LOL!
------------------
Andrew Nerney
Hapless Programmer
[email protected]