Hello again.
Let me get straight to the point.
I have a combobox, which I use to store the ComboText as well as the number of times that particular word(s) was clicked on inthat session. The code I use for the Combobox looks like:
Then, I save this info into a text file with the following sub, when I exit the app:Code:Private Sub cboSSCourse_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboSSCourse.SelectedIndexChanged If cboSSCourse.SelectedIndex > -1 Then 'if something selected iSS = cboSSCourse.SelectedIndex 'set = to sel index SSSubCount(iSS) += 1 SSSubs(iSS) = cboSSCourse.Text & " " & CStr(SSSubCount(iSS)) & ";" End If
Code:Private Sub SSWriteToFile(ByVal Path As String) Dim stream_writer As IO.StreamWriter Dim i As Integer ' Save the file. stream_writer = New IO.StreamWriter(Path, True) For i = 0 To SSSubs.Length - 1 stream_writer.Write(SSSubs(i)) Next stream_writer.Close() End Sub
This produces a Text file that looks like this:
This works perfectly.Code:ASP 2 Advanced 2;Corel Draw 10 Foundation 1;Dreamweaver Advanced 1;Business Finance 1;Director Foundation 1;Excel 2000 Advanced 1;ASP 2 Advanced 5;Dreamweaver Advanced 1
Now, what I need to do is to obtain a list of all the duplicates, alongwith their associated "click times" (which is the number next to the text, before the semi colon)
So, I did this:
This sub gets all the items within the textfile, and calls this function (to check for duplicates):Code:Private Sub SSGetSubFileInfo(ByVal Path As String) Dim stream_reader As IO.StreamReader Dim i As Integer 'Dim j As Integer stream_reader = New StreamReader(Path, True) SSubText = stream_reader.ReadToEnd().Split(";") stream_reader.Close() ReDim SSFileSub(SSubText.Length - 1) ReDim SSFileCount(SSubText.Length - 1) For i = 0 To SSubText.Length - 1 SSFileSub(i) = SSubText(i).Substring(0, SSubText(i).LastIndexOf(" ")) SSFileCount(i) = SSubText(i).Substring(SSubText(i).LastIndexOf(" "), 2) If SSOrganiseList(SSFileSub) Then Console.WriteLine(SSFileSub(i)) Console.WriteLine(SSFileCount(SSDup(i))) End If Next End Sub
The problem is, once it has found a duplicate item, it stops counting.Code:Private Function SSOrganiseList(ByVal arr As Array) As Boolean ReDim SSDup(arr.Length - 1) For i As Integer = 0 To arr.Length - 1 If Not arr(i) Is Nothing Then Dim l As Integer = Array.LastIndexOf(arr, arr(i)) If l <> i Then ' SSDupsFound += 1 SSDup(i) = i ' SSDup2 = l Return True ' Return SSDupsFound End If End If Next Return False End Function
What I'm trying to say is, it finds ASP 2 Advanced as a duplicate, with its "click time", it finds Dreamweaver Advanced as a duplicate, but doesn't find its "click time"
I need to find the items, then add together all their respected click times, for example:
ASP 2 Advanced has 5, then 2
So the total must be 7
Dreamweaver Advanced has 1 and 1 so the total must be 2
Any ideas on how I can achieve this?




Reply With Quote