[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PLEASE HELP: Listview Issue

Posted on 2006-10-29
2
Medium Priority
?
197 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 143

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 2000 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

Technology Partners: 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

872 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