Solved

PLEASE HELP: Listview Issue

Posted on 2006-10-29
2
191 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
[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
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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

738 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