Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb6 ListView1 = ListView2

Posted on 2010-11-12
3
Medium Priority
?
1,010 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 2000 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 101

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

670 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