Solved

vb6 ListView1 = ListView2

Posted on 2010-11-12
3
1,000 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Cannot Load VB6 on Windows 10. Installed OK but error on opening existing project. 7 85
vb6 connector to mongodb 2 81
using web browser with BING 40 119
MsgBox 4 59
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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.
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…

785 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