| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
||||
|
||||
|
A 'Parse' function.
Option Explicit
Private Sub Command1_Click() Dim A As Variant Dim i As Integer i = 1 A = Parse("hello To you", " ") Do While A(i) <> "" MsgBox A(i) i = i + 1 Loop End Sub Public Function Parse(sIn As String, sDel As String) As Variant Dim i As Integer, x As Integer, s As Integer, t As Integer i = 1: s = 1: t = 1: x = 1 ReDim tArr(1 To x) As Variant If InStr(1, sIn, sDel) <> 0 Then Do ReDim Preserve tArr(1 To x) As Variant tArr(i) = Mid(sIn, t, InStr(s, sIn, sDel) - t) t = InStr(s, sIn, sDel) + Len(sDel) s = t If tArr(i) <> "" Then i = i + 1 x = x + 1 Loop Until InStr(s, sIn, sDel) = 0 ReDim Preserve tArr(1 To x) As Variant tArr(i) = Mid(sIn, t, Len(sIn) - t + 1) Else tArr(1) = sIn End If Parse = tArr End Function |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > A 'Parse' function. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|