OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How split a text

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
flash
Newbie
Newbie


Joined: 08 Dec 2005
Posts: 2

PostPosted: Thu Dec 08, 2005 9:58 am    Post subject: How split a text Reply with quote

I would like to 'split' a text and I don't how use correctly the split() function.

For example I have these data in the cell A1: (1:2)(3:4)
And I would like to get finally these values in four different cells : A2= 1, A3=2, A4=3 and A5=4
How can I get it?

Thanks for your help
Back to top
View user's profile Send private message
flash
Newbie
Newbie


Joined: 08 Dec 2005
Posts: 2

PostPosted: Thu Dec 08, 2005 10:34 am    Post subject: Reply with quote

After tests, I have this solution but maybe it exists a better one :

Sub Main

Dim sText as String
Dim round as Long
Dim character as String
Dim resu() as String
Dim x as Long

sText=InputBox("how do you want to split :")

For round=1 to 2

Select Case round
Case 1
character="("
Case 2
character=")"
End Select

resu=split(sText,character)
sText=join(resu(),":")

Next

resu=split(sText,":")

For x=LBound(resu) to UBound(resu)
If resu(x)<>"" Then
Print x, resu(x)
End if
Next

End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group