For example if you are having the strings like "34124 123434 12341241 1234124 213412 12 1234 234 1234 1234 1234". Here the delimiter for each set of numbers is space. So by using the following function you can split each set of values. This function need the following parameters:
1.String which contains the set of values. It should be passed by value. (psRecord) 2.Object which going to hold the set of values seperately. It should be passed by value. (newstart) 3.Demiliter String which means the any character that you want to mark it as a delimiter.It should be passed by value. (delimiter)
Function StringSpliter(ByVal psRecord As String,ByRef newstart as Object, ByVal delimiter as string) Dim liLength, liStart, liUpto, liCounti, liCountj As Integer
Dim licount, liLength, piCount As Integer
liLength = Len(psRecord) piCount = 0 For licount = 1 To liLength If Mid(psRecord, licount, 1) = " " Then piCount = piCount + 1 End If Next
newstart="" ReDim newstart(piCount) liLength = Len(psRecord) liCountj = 0 For liCounti = 1 To liLength If Mid(psRecord, liCounti, 1) = delimiter Then liStart = liCounti If liCountj = 0 Then newstart(liCountj) = Mid(psRecord, 1, liStart - 1) liUpto = liCounti + 1 Else newstart(liCountj) = Mid(psRecord, liUpto, liStart - liUpto) liUpto = liCounti + 1 End If liCountj = liCountj + 1 ElseIf liCountj = piCount Then liUpto = liCounti newstart(liCountj) = Mid(psRecord, liUpto) Exit For End If Next End Function
|
| Author: Ganesh 20 Jul 2007 | Member Level: Bronze Points : 0 |
Though Logic is good, Split function exists in C#.
Check this link which explains the split function
http://www.peachpit.com/articles/article.asp?p=31938&seqNum=14&rl=1
|