• Welcome to Valhalla Legends Archive.
 

Help with this.

Started by GoSu_KaOs, January 26, 2005, 05:38 PM

Previous topic - Next topic

GoSu_KaOs

I got Listview1, Listview2, Cmd1, Cmd2

This is the code for cmd1:

Private Sub Cmd1_Click()
listview1.listitems.add ,, "item1:change1"
listview1.listitems.add ,, "item2:change2"
listview1.listitems.add ,, "item3:change3"
listview1.listitems.add ,, "item4:change4"
end sub


Split meathod that I found ( I didn't change it for use in my program yet):

Dim Splt() as String
Splt() = Split(listview.FindItem(item).Text, ":")
split0.Text = Splt(0)
split1.Text = Splt(1)


I need this:
When you press Cmd2, It checks all the items in Listview1 then from all those items, it gets only
the text before the ":" and compares them to listview2's items. If any of the items are the same, it replaces them with the text after ":".
Ex: If Listview1 has the item "item1:change1", and Listview2 has "item1", it renames listview2's "item1"  to "change1"

This got too confusing for me, so I'm askin on the forums.

GoSu_KaOs

Nm, got it... >:(

Private Sub Command1_Click()
Dim itm1 As ListItem, itm2 As ListItem
Dim str1 As String, str2 As String

For Each itm1 In listview1.ListItems 'loop the first listview
If InStr(1, itm1.Text, ":") Then 'just make sure ":" is in there
  str1 = Left$(itm1.Text, InStr(1, itm1.Text, ":") - 1) 'get the leftside of ":"
  str2 = Mid$(itm1.Text, InStr(1, itm1.Text, ":") + 1) 'get the rightside of ":"
   
   For Each itm2 In listview2.ListItems 'loop second listview
    If itm2.Text = str1 Then 'see if it matches the string
     itm2.Text = str2 'if it does, change it
    End If
   Next itm2
End If
Next itm1
End Sub

Private Sub Command2_Click()
listview1.ListItems.Add , , "item1:change1"
listview1.ListItems.Add , , "item2:change2"
listview1.ListItems.Add , , "item3:change3"
listview1.ListItems.Add , , "item4:change4"
End Sub

Private Sub Command3_Click()
listview2.ListItems.Add , , "item1"
listview2.ListItems.Add , , "item2"
listview2.ListItems.Add , , "item3"
listview2.ListItems.Add , , "item4"
End Sub