Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find exact valute in listview and return the row index

Status
Not open for further replies.

2009luca

Programmer
Jul 27, 2013
222
IT
I Just have myvar=test, how to find in column 12, and return the index row?
 
...and what have you tried?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Olny a simple loop an column 12.
But a few time ago i remember the use of find statement
 
Listview has a Finditem method - but this does not allow you to search within a particular subitem column

Here's the Hel File entry (as I have previously advised - and provided a link to - the help file is really useful; not using it once again suggests that you think our time is less valuable than yours ...)

Code:
[b]FindItem Method (ListView Control)[/b]
      
Finds and returns a reference to a ListItem object in a ListView control.

[b]Syntax[/b]

[i]object[/i][i][/i].FindItem ([i]string, value, index, match[/i])

The FindItem method syntax has these parts:

[b]Part            Description[/b] 
[i]object[/i]          Required. An object expression that evaluates to a ListView control. 
[i]string[/i]          Required. A string expression indicating the ListItem object to be found. 
[i]value[/i]           Optional. An integer or constant specifying whether the string will be matched to the ListItem object's Text, Subitems, or Tag property, as described in Settings. 
[i]index[/i]           Optional. An integer or string that uniquely identifies a member of an object collection and specifies the location from which to begin the search. The integer is the value of the Index property; the string is the value of the Key property. If no index is specified, the default is 1. 
[i]match[/i]           Optional. An integer or constant specifying that a match will occur if the item's Text property is the same as the string, as described in Settings. 

[b]Settings[/b]

The settings for value are:

[b]Constant   Value   Description[/b] 
lvwText    0       (Default) Matches the string with a ListItem object's Text property. 
lvwSubitem 1       Matches the string with any string in a ListItem object's SubItems property. 
lvwTag     2       Matches the string with any ListItem object's Tag property. 

The settings for match are:

[b]Constant     Value  Description[/b] 
lvwWholeWord 0      (Default) An integer or constant specifying that a match will occur if the item's Text property begins with the whole word being searched. Ignored if the criteria is not text. 
lvwPartial   1      An integer or constant specifying that a match will occur if the item's Text property begins with the string being searched. Ignored if the criteria is not text. 

[b]Remarks[/b]

If you specify Text as the search criteria, you can use lvwPartial so that a match occurs when the ListItem object's Text property begins with the string you are searching for. For example, to find the ListItem whose text is "Autoexec.bat", use:

'Create a ListItem variable.
Dim itmX As ListItem
'Set the variable to the found item.
Set itmX = ListView1.FindItem("Auto",,,lvwpartial)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top