Solved

vb6 ListView1 = ListView2

Posted on 2010-11-12
3
1,005 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 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