Solved

vb6 ListView1 = ListView2

Posted on 2010-11-12
3
1,002 Views
Last Modified: 2013-12-25
Hi There,

I have this form in VB6 in which I have several ListViews. Turns out that I have a For/Next loop to run in each one of those listviews, however I did not want to have to rewrite the loop for each one of the listview. So, I am now trying to find a way to create a method/function in which I pass the ListView control to, run the loop in the items in that list, performing the changes as necessary such as checking on/off the check box, and then returning the revewed listview back from that function.

Something like....

Private Function ChangeListView(lvwX as ListView) as ListView
   For i = 1 To lvwX.ListItems.Count
     if lvwX.ListItems(i).Text = "abc" then
        lvwX.ListItems(i).Checked = True
     end if
   Next i
End Function

Then I would do....
ListView1 = ChangeListView(ListView1)

Everything goes well until I return from my function with my changed listview. I won't let me make the ListView1 = My new Listview

Suggestions?!

Thx a bunch..

Ed.
0
Comment
Question by:edusabrz
3 Comments
 
LVL 13

Accepted Solution

by:
rettiseert earned 500 total points
ID: 34122777
Hi

When you asign reference variables you need to use the set keyword, for example
set ListView1 = ChangeListView(ListView1)

however, I think tha'ts not what you need. Perhaps you just need to run your function as is, without needing for assing nothing, e.g.

Private Sub ChangeListView(lvwX as ListView)
   For i = 1 To lvwX.ListItems.Count
     if lvwX.ListItems(i).Text = "abc" then
        lvwX.ListItems(i).Checked = True
     end if
   Next i
End Sub

ChangeListView(ListView1)
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34904997
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question