|
-
Dec 20th, 2003, 11:31 AM
#1
Thread Starter
Member
Newbie question
task is to change a value in a listbox to another value,
e.g
3.40
changing the price of 3.40 to 4.30 :/ if u get me!
Well heres the code that i thought it may be but i dont no sory biggest newb here 
VB Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
lstboxpric.SelectedItem = numhire.Value + lstboxpric.SelectedItem
End Sub
-
Dec 20th, 2003, 11:44 AM
#2
Sleep mode
VB Code:
Private Sub ChangeItem(ByVal SelectedItem As Integer, ByVal NewItem As String)
'NewItem =The new value you want to add
'SelectedItem =Index of the value you want to change
Me.ListBox1.Items.RemoveAt(SelectedItem)
Me.ListBox1.Items.Insert(SelectedItem, NewItem)
End Sub
use it like this :
VB Code:
ChangeItem(Me.ListBox1.SelectedIndex, Me.TextBox1.Text)
Make sure that there is an item selected . I left out error handling for you .
-
Dec 20th, 2003, 12:54 PM
#3
Thread Starter
Member
VB Code:
ChangeItem(Me.ListBox1.SelectedIndex, Me.TextBox1.Text)
confused me 
EDIT:
n nope the remove at function didnt work either )
Last edited by Ezpz; Dec 20th, 2003 at 12:58 PM.
-
Dec 20th, 2003, 12:56 PM
#4
Sleep mode
-
Dec 20th, 2003, 01:01 PM
#5
Sleep mode
Originally posted by Ezpz
VB Code:
ChangeItem(Me.ListBox1.SelectedIndex, Me.TextBox1.Text)
confused me 
EDIT:
n nope the remove at function didnt work either )
What do you mean it didn't work ? any error ?
-
Dec 20th, 2003, 01:04 PM
#6
Thread Starter
Member
VB Code:
ChangeItem(Me.ListBox1.SelectedIndex, Me.TextBox1.Text)
on that line the change item bit was underlined as exception error :/
and the other bit of code just didnt do anything no build errors or nothing, but i presume thats down to the line above not working :/ so i removed
VB Code:
Me.ListBox1.Items.Insert(SelectedItem, NewItem)
to see if i could remove the value in list box but still it wouldnt do nothing..
i checked to make sure it was assigned to correct button and it was :/.
-
Dec 20th, 2003, 01:06 PM
#7
Sleep mode
Show me how did you use it in your code ?
-
Dec 20th, 2003, 01:41 PM
#8
Thread Starter
Member
Private Sub ChangeItem(ByVal SelectedItem As Integer, ByVal NewItem As String)
'NewItem =The new value you want to add
'SelectedItem =Index of the value you want to change
Me.ListBox1.Items.RemoveAt(SelectedItem)
ChangeItem(Me.ListBox1.SelectedIndex, Me.TextBox1.Text)
Me.ListBox1.Items.Insert(SelectedItem, NewItem)
End Sub
-
Dec 20th, 2003, 01:52 PM
#9
Sleep mode
See here how you should use it . It's VB.NET 2003 project .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|