Solved

PLEASE HELP: Listview Issue

Posted on 2006-10-29
2
186 Views
Last Modified: 2010-04-30
Hello All,
I have a listview with two 3 columns
columns:
Checkbox
String
Double

I need a way to find the string, get the double value of that row, then add another value to the existing value, then update the row's double value based on the string

Find string widget
value1 = current value in row

value2 = another value

value3 = new value

 (value1 + value2 = value3)
(1 + 1 = 2)

I wish to put value3 in the location of value1

Thanks again.
0
Comment
Question by:dheffley
2 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17829345
dim l as long
dim i as Listitem

for l = 1 to listview.listitems.count
  set i = listview.listitems(l)
  if i.subitems(1) = "widget" then
     i.subitems(2) = i.subitems(2) + value2
  end if
next

0
 
LVL 14

Accepted Solution

by:
Shiju Sasidharan earned 500 total points
ID: 17831626
place a listview, combobox and command button and try this code

Private Sub Command1_Click()
Dim oLst As ListItem
    Set oLst = ListView1.FindItem(Combo1.Text, lvwText)
    If oLst Is Nothing Then
        MsgBox "Unable to find searched string", vbExclamation
    Else
        MsgBox "Found element", vbInformation
        oLst.SubItems(1) = Val(oLst.SubItems(1)) + 1 'Adding 1 to item
        oLst.Selected = True
    End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim oLst As ListItem
    ListView1.ColumnHeaders.Clear
    ListView1.ColumnHeaders.Add , , "String", 2000
    ListView1.ColumnHeaders.Add , , "Double", 2000
    ListView1.View = lvwReport
    ListView1.HideSelection = False
    Combo1.Clear
    Command1.Caption = "Find and Add"
    For i = 1 To 10
        Set oLst = ListView1.ListItems.Add(, , "String" & i)
        'simply adding some random values
        oLst.SubItems(1) = Int(Rnd * 10)
        'adding search string
        Combo1.AddItem "String" & i
    Next
    Combo1.ListIndex = 0
End Sub
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…

758 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

20 Experts available now in Live!

Get 1:1 Help Now