Link to home
Start Free TrialLog in
Avatar of Philippe Renaud
Philippe RenaudFlag for Canada

asked on

How to modify a value inside a 1 dimension listBox

Hello EE,

Lets say I have a Listbox that has been filled with a 1 dimensional array such as

1, 0
100,1
455,2
900,3
etc

how do I modify a single value inside it?


in other words see my code... I know its not good but lets say oldValue = 455  want to modify it so it will be replace by  -1

any ideas?
For x As Integer = 0 To ListBox4.Items.Count - 1
                Dim myMatch As New MatchData
                myMatch = ListBox4.Items(x)
                If myMatch.Value = oldValue Then
                    ListBox4.Items(x)(0) = "Done"
                End If
            Next

Open in new window

Avatar of Philippe Renaud
Philippe Renaud
Flag of Canada image

ASKER

sorry its not "done" in the code  but   -1
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I understand what your line does, but, the problem is that if I have multiple same values.. it would find 2 rows

does it have like a FindStringExactAt   lol?   for index or something?

do you know what I mean
Your loop will do the same as well!
lol right. sorry ;)
mmm..  is it possible that it replace all the item at  my index by new value ?  Like if it was becoming a non dimensional line ?

becasue I am having an error saying unable to cast int32 type to  [.....] MatchData

MatchData is a combinaison of 2 values    (value and index)

i woudl like to keep the index but just modify the value.. not sure if Im doing this correctly with your last comment


or am i wrong ?
My approach would not work with items of a custom type. Looping would work though.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks
hey guys :)

if you didnt see it, I have another question here :

https://www.experts-exchange.com/questions/26968746/Linq-Where-clause.html