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

x
?
Solved

How to modify a value inside a 1 dimension listBox

Posted on 2011-04-20
10
Medium Priority
?
380 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:PhilippeRenaud
  • 6
  • 3
10 Comments
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35433662
sorry its not "done" in the code  but   -1
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 800 total points
ID: 35433697
Try

Listbox1.Items(Listbox1.FindStringExact(oldvalue)) = newvalue
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35433745
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
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35433777
Your loop will do the same as well!
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35433808
lol right. sorry ;)
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35433854
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 ?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35433962
My approach would not work with items of a custom type. Looping would work though.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1200 total points
ID: 35434216
Something like:
For md As MatchData in ListBox4.Items
            If md.Value = oldValue Then
                md.Value = -1
            End If
        Next

Open in new window

0
 
LVL 1

Author Closing Comment

by:PhilippeRenaud
ID: 35434477
thanks
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35436910
hey guys :)

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

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_26968746.html
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
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