Solved

vb6 ListView1 = ListView2

Posted on 2010-11-12
3
990 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now