Hello Cor,
I ran into the same problem that this person did
From: Tina (
[email protected])
Subject: ArrayList problem
Newsgroups: microsoft.public.dotnet.languages.vb
Date: 2003-07-14 15:24:02 PST
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=e#
p4eYlSDHA.2188%40TK2MSFTNGP10.phx.gbl&rnum=2&prev=/groups%3Fq%3DLateboun
d%2Bassignment%2Bto%2Ba%2Bfield%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUT
F-8%26selm%3De%2523p4eYlSDHA.2188%2540TK2MSFTNGP10.phx.gbl%26rnum%3D2
and changed my code based on the suggestions she received.
I am having problem actually incrementing a member of the structure.
Here is my code
----------------------------
Option Strict On
Public Class test
Inherits System.Windows.Forms.Form
Public Structure countInfo
Public word As String
Public num As Integer
End Structure
Private Sub btnClick_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClick.Click
Dim y As New ArrayList
Dim infolist As New ArrayList
Dim strIn, str As String
Dim strOut() As String
Dim i, index As Integer
Dim z1 As countInfo
' string to parse
strIn = txtInfo.Text
' parse results
strOut = strIn.Split(CChar(" "))
' save the string the first time
' next time, incement its number
For i = 0 To strOut.GetLength(0) - 1
str = CStr(strOut.GetValue(i))
index = y.IndexOf(str)
If Not index >= 0 Then
y.Add(str)
Dim newInfo As countInfo
newInfo.word = CStr(str)
newInfo.num = 1
infolist.Add(newInfo)
Else
For Each z1 In infolist
If str = z1.word Then
' z1.num gets incremented
' but the actual structure in the
' array does not
z1.num += 1
Exit For
End If
Next
End If
Next
' this works fine
For Each z In infolist
txtOut.AppendText(z.word)
txtOut.AppendText(" ")
txtOut.AppendText(CStr(z.num))
txtOut.AppendText(Constants.vbNewLine)
Next
End Sub
End Class
--------------
I would appreciate your help.
Thanks ,
Burak