Solved

PLEASE HELP: Listview Issue

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

685 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