Serpe
17-06-2004, 17:02
volevo fare una funzione che passatagli una stringa e un separatore mi restituisse una collection con le sub-stringhe che il separatore delimita
Sub passastr()
Dim j As New Collection
stringa = "a;Bcdefg;ghek;ehsie;"
sep = ";"
Set j = DS(stringa, sep)
End Sub
Function DS(ByVal stringa As String, ByVal sep As String) As Collection
Dim substr As New Collection
k = 1 'posini
y = 0 'posfina
Do
y = InStr(k, stringa, sep, vbTextCompare) 'si becca il valore della posiozne del separatore
If y > 0 Then
substr.Add Mid(stringa, k, y - k)
k = y + 1
End If
Loop While y > 0
DS = substr
End Function
ho un errore di compilazione in :
DS1 = substr
dove mi dice "Argomento non facoltativo" , ma non ho capito quale elemento vuole
qualche suggerimento?
Sub passastr()
Dim j As New Collection
stringa = "a;Bcdefg;ghek;ehsie;"
sep = ";"
Set j = DS(stringa, sep)
End Sub
Function DS(ByVal stringa As String, ByVal sep As String) As Collection
Dim substr As New Collection
k = 1 'posini
y = 0 'posfina
Do
y = InStr(k, stringa, sep, vbTextCompare) 'si becca il valore della posiozne del separatore
If y > 0 Then
substr.Add Mid(stringa, k, y - k)
k = y + 1
End If
Loop While y > 0
DS = substr
End Function
ho un errore di compilazione in :
DS1 = substr
dove mi dice "Argomento non facoltativo" , ma non ho capito quale elemento vuole
qualche suggerimento?