Valhalla Legends Forums Archive | Visual Basic Programming | Compare Problems

AuthorMessageTime
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

[code]
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
[/code]

Is there another way I should use xor?

February 11, 2004, 10:08 PM
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?
February 11, 2004, 10:54 PM
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.
February 13, 2004, 5:03 PM
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.
February 13, 2004, 5:37 PM
Imperceptus
Good suggestion, thanks Grok.
February 13, 2004, 5:43 PM

Search