• Welcome to Valhalla Legends Archive.
 

Compare Problems

Started by Imperceptus, February 11, 2004, 04:08 PM

Previous topic - Next topic

Imperceptus

I am loading a file into a multi dem array and comparing values against a listview.  
I was thinking of using xor to compare, seeing that if the value was false then it would mean a match was not found in array listview compare.

This is what I have


Public Sub ExportListToFile(ByVal ctrlListView As ListView, ByVal strFilePath As String, Optional ByVal AllowDuplicates As Boolean = False)
Dim StrSplit() As String, CrSplit() As String, FileExists, FileContents, DupNotExist As Boolean
Dim c As Integer, s As Integer, n As Integer, f As Integer
   If FileExists = Not Dir(strFilePath) = "" Then Open strFilePath For Random As #1: Close #1
   FileContents = FileToVar(strFilePath)
   CrSplit = Split(FileContents, vbCrLf)
   Open strFilePath For Append As #1
   ReDim DuplicationArray(UBound(CrSplit) + ctrlListView.ListItems.Count, 15)
   For c = LBound(CrSplit) To UBound(CrSplit)
       StrSplit = Split(CrSplit(c), Chr(255))
       For s = LBound(StrSplit) To UBound(StrSplit)
           DuplicationArray(c, s) = StrSplit(s)
       Next s
   Next c
   For n = 1 To ctrlListView.ListItems.Count
       For f = 0 To UBound(CrSplit) - 1
           'DupNotExist = DuplicationArray(n, 1) Xor vbNull
           If Not ctrlListView.ListItems(n).ListSubItems(1).Text = DuplicationArray(n, 1) Then GoTo FoundDup
           
       Next f

       Print #1, GrabRow(ctrlListView, n)
FoundDup:
   Next n
   Close #1
End Sub


Is there another way I should use xor?

Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

Grok

Can you explain your goal, in English?

What is in these listviews?  What are you trying to compare to the listview contents?  What matches do you want to keep and want to discard?

Imperceptus

List view keeps contents of GPS coordinates of things,  every so often I need to export the contents of the listview to a file and make sure there are no duplicate values.

Im trying to compare the GPS values against the ones already saved in the text file and if there is not a match then to write the value to the file.

I want to discard matches. and keep only what doesnt match.
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

Grok

Oh, easy.  Keep the list separate from the listview.  Update the listview from the list, not the other way around.

When the list changes, clear the listview and reload it.

Can users make changes to the listview?  If so, immediately put those changes in the list and write to file when they click Save.

Try to keep the GUI as a presentation layer only, and keep your business rules in the data object model in memory only.  Use that object model (in this case just a list) to serialize to your file system.

Imperceptus

Good suggestion, thanks Grok.
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.