Newsgroup: it.comp.lang.visual-basic
Titolo: [vb6->vb5] funzione Split

Sto convertendo un progetto da vb6 a vb5.
Chi mi manda per favore due righe sulla funzione Split, che in vb5 non
esiste?
mi basta la sintassi e piu' o meno cosa fa.
Grazie e tanti auguri!

Cerca qui:
http://msdn.microsoft.com
Comunque la funzione split divide una stringa in un variantarray in base ad
una sottostringa
Es.:
Dim A variant
A = split ("Ciao mamma"," ")
A diventerà un array di 2 elementi (0 e 1 di indice)
A(0)="Ciao"
A(1)="mamma"
                Ciao
                                Allanon

Via... E' Natale... regalino di Natale di Allanon... :)
Option Explicit
Private Sub Form_Load()
    Dim A
    A = Split("Ciao mamma guarda come mi diverto!", " ")
    Dim N As Long
    For N = 0 To UBound(A)
      MsgBox A(N)
    Next N
End Sub
Function Split(StringaDaDividere As String, StringaDivisoria As String,
Optional Limit As Long = -1, Optional CompareMode As vbcomparemethod =
vbBinaryCompare) As Variant
    Dim N As Long
    Dim K As Long
    Dim Arr() As String
    N = Val(InStr(1, StringaDaDividere, StringaDivisoria, CompareMode))
    K = 1
    ReDim Arr(0)
    Do Until N = 0
      If Limit > -1 Then
        If N > Limit Then
          Exit Do
        End If
      End If
      Arr(UBound(Arr)) = Mid$(StringaDaDividere, K, N - K)
      K = N
      N = Val(InStr(N + Len(StringaDivisoria), StringaDaDividere,
StringaDivisoria, CompareMode))
      ReDim Preserve Arr(UBound(Arr) + 1)
    Loop
    Arr(UBound(Arr)) = Mid$(StringaDaDividere, K + Len(StringaDivisoria))
    Split = Arr
End Function
            Ciao & auguri!
                    Allanon

 ha scritto

sotto msdn e un esempio.
ciao, j.
--
www.sundaysw.com
Split Function
Description
Returns a zero-based, one-dimensionalarray containing a specified number of
substrings.
Syntax
Split(expression[, delimiter[, count[, compare]]])
The Split function syntax has these parts:
      Part Description
      expression Required.String expression containing substrings and
delimiters. If expression is a zero-length string(""), Split returns an
empty array, that is, an array with no elements and no data.
      delimiter Optional. String character used to identify substring
limits. If omitted, the space character (" ") is assumed to be the
delimiter. If delimiter is a zero-length string, a single-element array
containing the entire expression string is returned.
      count Optional. Number of substrings to be returned; -1 indicates that
all substrings are returned.
      compare Optional. Numeric value indicating the kind of comparison to
use when evaluating substrings. See Settings section for values.
Settings
The compare argument can have the following values:
      Constant Value Description
      vbUseCompareOption -1 Performs a comparison using the setting of the
Option Compare statement.
      vbBinaryCompare 0 Performs a binary comparison.
      vbTextCompare 1 Performs a textual comparison.
      vbDatabaseCompare 2 Microsoft Access only. Performs a comparison based
on information in your database.
---
prova di servizio nt.
serviva a ricopiare un file su una dir di bkp:
 Private Sub cmdExec2_Click()
    Dim fName As String, nLine As String
    Dim fNum As Integer, lConf As Long, lRet As Long
    Dim fSrc As String, fTrg  As String
    Dim str() As String
    fNum = FreeFile
    fName = App.Path & "\exec3.txt"
    Open fName For Input As #fNum
    Do Until EOF(fNum)
        Line Input #fNum, nLine
        str() = Split(nLine, ";")
        fSrc = str(0) & str(1) & ".txt"
        fTrg = "c:\bkp\" & str(1) & "_old.txt"
        Print fSrc
        Print fTrg
        FileCopy fSrc, fTrg
    Loop
End Sub
exec3.txt:
C:\vbprog\altri\ntservice\test1\;txt1
C:\vbprog\altri\ntservice\test1\;txt2

volendo proprio essere pigri, da vb5 crei un oggetto scripting (vbscript) e
usi la funzione split.
marco