Hello,
I ran into the same problem that this person did
From: Tina (tinamseaburn@excite.com)
Subject: ArrayList problem
Newsgroups: microsoft.public.dotnet.languages.vb
Date: 2003-07-14 15:24:02 PST
http://groups.google.com/groups?hl=...3p4eYlSDHA.2188%40TK2MSFTNGP10.phx.gbl&rnum=2
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
I ran into the same problem that this person did
From: Tina (tinamseaburn@excite.com)
Subject: ArrayList problem
Newsgroups: microsoft.public.dotnet.languages.vb
Date: 2003-07-14 15:24:02 PST
http://groups.google.com/groups?hl=...3p4eYlSDHA.2188%40TK2MSFTNGP10.phx.gbl&rnum=2
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