Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This program shows the use of dynamic arrays and s...
Author:
Theodore W. Barkhuizen
E-mail:
Click to e-mail author
Submitted:
4/1/2002
Version:
VB6
Compatibility:
VB6
Category:
String Manipulation
Views:
15899
This program shows the use of dynamic arrays and string manipulation functions like Mid$,Right$,Left$ and Instr to write your own Split function found in VB6.
Declarations:
Option Explicit Dim sentence As String Dim wordArray() As String
Code:
Private Sub cmdSplit_Click() Dim counter As Integer sentence = txtSentence.Text Call SplitSentence(sentence) For counter = LBound(wordArray) To UBound(wordArray) lstDisplay.AddItem wordArray(counter) Next counter End Sub Private Sub SplitSentence(strSentence As String) Dim position As Integer Dim word As String ReDim wordArray(0) position = InStr(1, strSentence, " ") Do While position <> 0 word = Left$(strSentence, position - 1) ReDim Preserve wordArray(UBound(wordArray) + 1) wordArray(UBound(wordArray) - 1) = word strSentence = Right$(strSentence, Len(strSentence) - position) position = InStr(1, strSentence, " ") Loop word = strSentence ReDim Preserve wordArray(UBound(wordArray) + 1) wordArray(UBound(wordArray) - 1) = word End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement