Tekstsorteerder: code
- De routine die de analyse doorvoert wordt opgeroepen door de knop:
Sub analyse(instring As String)
Dim lettre As String
Dim mot As String
Dim pos As Integer
For pos = 1 To Len(instring)
lettre = Mid(instring, pos, 1)
Select Case lettre
Case " ", ".", ","
ajouter mot
mot = ""
Case Else
mot = mot & lettre
End Select
If pos = Len(instring) Then
ajouter mot
mot = ""
End If
Next pos
End Sub
- We moeten nagaan of een woord al in de lijst voorkomt. Daarvoor gaan we de hele lijst na
om te zien of het woord er in staat.
Function dejamis(mot As String) As Boolean
Dim t As Integer
For t = 0 To List1.ListCount
If mot = List1.List(t) Then
dejamis = True
Exit Function
End If
Next t
End Function
- Om een woord toe te voegen, voegen we het toe als het nog niet in de lijst staat.
Sub ajouter(mot As String)
If Not dejamis(mot) Then List1.AddItem mot
End Sub
[VB Web] - [hlrnet] - [copyright]