by Vincent Viau (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 18th July 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This procedure will decompose a string into chunks of a chosen lenght. You can also chose where to start in the string. Very handy for word
'L is the starting position in the string
'W is the string to decompose
'R is the lenght of the decomposed chunks of the string
'Example: PString 0,1,"Vincent" will give
'V
'i
'n
'c
'e
'n
't
'Example2: PString 0,2,"Vincent" will give
'Vi
'nc
'en
't
Dim dword()
On Error GoTo skip
'error handling
If Len(W) < L Then
lstword.AddItem " PSTRING ERROR, START POSITION > WORD LENGHT!"
Exit Sub
End If
Do While Len(W) Mod R <> 0 ' Si R est un facteur de W ( C'est requis )
W = W & " " ' Auguemente la longeur de W par 1
Loop
skip:
W = W & " " ' Auguemente la longeur de W par 1 un derniere fois
ReDim dword(R To (Len(W))) 'Définir les parametres du array ex: (1 to 12)
For L = R + L To (Len(W)) Step R ' Boucle qui auguemente par R (l'intervalle)
dword(L) = Right(Left(W, L), R) ' Ce qui décompose le mot ( Compliqué)
If L = Len(W) Then ' Si c'est la derniere partie du mot
RTrim (dword(L)) ' enlever les espaces a la fin de cette partie du mot
End If
lstword.AddItem dword(L) 'Montrer les décompositions
Text1.Text = dword(L)
Next L
End Sub
No comments have been posted about This procedure will decompose a string into chunks of a chosen lenght. You can also chose where to . Why not be the first to post a comment about This procedure will decompose a string into chunks of a chosen lenght. You can also chose where to .