[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Multi Split

Posted on 2004-09-04
4
Medium Priority
?
182 Views
Last Modified: 2008-03-06
i want make function SplitDelimiter

Syntax : SplitDelimter(strText,strDelimiter) reture with array

example a = SplitDelimter("hello you:can you?me"," :?")
reture array like this

a(0) = "hello"
a(1) = "you"
a(2) = "can"
a(3) = "you"
a(4) = "me"

how can i do this function can anyone give me the source code.

please dont use For i = 1 to Len(strText) ... Next i
because it make function slow.

thanks you.
0
Comment
Question by:InVisal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 11980401
If you are using VB6 it has this built in already.  Its called the Split function.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 11980410
If using VB5 or previous, use this:
http://www.devx.com/vb2themax/Tip/19090
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 11980414
Oh, I see what you want...you want to use any one of those characters as a delimeter.  Sorry.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 480 total points
ID: 11980423
The only way to accomplish this (without looping as requested) is to replace all the delimiters you are interested in with something else so you can use the Split() function:

Option Explicit

Private Sub Command1_Click()
    Dim i As Integer
    Dim a As Variant
   
    a = SplitDelimiter("hello you:can you?me", " :?")
    For i = LBound(a) To UBound(a)
        Debug.Print "a(" & i & ") = " & a(i)
    Next i
End Sub

Private Function SplitDelimiter(ByVal source As String, ByVal delimiters As String) As Variant
    Dim i As Integer
    Dim delimiter As String
   
    delimiter = Chr(1) & "/|\"" & Chr(1)" ' pick something unlikely to appear in the source string
    For i = 1 To Len(delimiters)
        source = Replace(source, Mid(delimiters, i, 1), delimiter)
    Next i
    SplitDelimiter = Split(source, delimiter)
End Function
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question