10 Replies - 850 Views - Last Post: 11 May 2013 - 04:00 AM Rate Topic: -----

#1 SuperKap51  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 10-May 13

How would I edit a ListBox item?

Posted 10 May 2013 - 03:09 PM

I want to be able to select an item in a listbox and then click an edit button and then be able to edit it with an input button. Can someone give me the code for this or start me off with some ideas?
Is This A Good Question/Topic? 0
  • +

Replies To: How would I edit a ListBox item?

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How would I edit a ListBox item?

Posted 10 May 2013 - 03:19 PM

View PostSuperKap51, on 10 May 2013 - 10:09 PM, said:

I want to be able to select an item in a listbox and then click an edit button and then be able to edit it with an input button. Can someone give me the code for this or start me off with some ideas?

Give me the code?! What have you tried?

You could start with the docs, or look through the Tutorials section.
Was This Post Helpful? 0
  • +
  • -

#3 SuperKap51  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 10-May 13

Re: How would I edit a ListBox item?

Posted 10 May 2013 - 03:22 PM

I don't know where to start? I know nothing about input boxes.
Was This Post Helpful? -1
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How would I edit a ListBox item?

Posted 10 May 2013 - 03:26 PM

You could not have read through that link I provided in two minutes, or have visited the tutorials.

View PostSuperKap51, on 10 May 2013 - 10:22 PM, said:

I don't know where to start? I know nothing about input boxes.

and there is no such thing as an inputbox, perhaps you mean a textbox.

This post has been edited by andrewsw: 10 May 2013 - 03:43 PM

Was This Post Helpful? 0
  • +
  • -

#5 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: How would I edit a ListBox item?

Posted 10 May 2013 - 03:39 PM

There actually is an inputbox. It's part of the Visualbasic namespace and unfortunately is still be taught in classes as a means to gather input from the user :(/>

This post has been edited by CharlieMay: 10 May 2013 - 03:40 PM

Was This Post Helpful? 1
  • +
  • -

#6 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How would I edit a ListBox item?

Posted 10 May 2013 - 03:42 PM

View PostCharlieMay, on 10 May 2013 - 10:39 PM, said:

There actually is an inputbox. It's part of the Visualbasic namespace and unfortunately is still be taught in classes as a means to gather input from the user :(/>/>

Of course! Don't know what I was thinking :). The OP confused me by first referring to an input button.
Was This Post Helpful? 0
  • +
  • -

#7 IronRazer  Icon User is online

  • D.I.C Addict

Reputation: 247
  • View blog
  • Posts: 804
  • Joined: 01-February 13

Re: How would I edit a ListBox item?

Posted 10 May 2013 - 04:07 PM

You should read the information at the link that CharlieMay gave to you. I have looked at it and i see they do not give a real good example of using it so here is a small example.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim output As String = ""

        output = InputBox("This is the question or comment", "This is the title", "You could put the listbox selected item here", -1, -1)

        MessageBox.Show(output)

    End Sub


From there you can read the Listbox Link that andrewsw gave to you and figure out how to get the text from the listbox using the (SelectedItem) method. Then to change the text in the listbox you could use the (Listbox.Item) and (SelectedItem) methods. Give it a shot and see what you can figure out. Someone here will help if you get stuck. B)
Was This Post Helpful? 0
  • +
  • -

#8 SuperKap51  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 10-May 13

Re: How would I edit a ListBox item?

Posted 11 May 2013 - 12:27 AM

This is what I have so far:
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim output As String = ""
        output = InputBox("Type the new message in the text box below.", "Edit Message", ListBox1.SelectedIndex, -1, -1)
        ListBox1.SelectedIndex = output
    End Sub


This is the error I get:
Conversion from string "xxxxxxxxxxxxxx" to type 'Integer' is not valid.
Was This Post Helpful? 0
  • +
  • -

#9 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How would I edit a ListBox item?

Posted 11 May 2013 - 02:36 AM

View PostSuperKap51, on 11 May 2013 - 07:27 AM, said:

This is the error I get:
Conversion from string "xxxxxxxxxxxxxx" to type 'Integer' is not valid.

So what is this error messaging telling you?
Was This Post Helpful? 0
  • +
  • -

#10 SuperKap51  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 10-May 13

Re: How would I edit a ListBox item?

Posted 11 May 2013 - 03:11 AM

InvalidCastException was unhandled.
Was This Post Helpful? 0
  • +
  • -

#11 IronRazer  Icon User is online

  • D.I.C Addict

Reputation: 247
  • View blog
  • Posts: 804
  • Joined: 01-February 13

Re: How would I edit a ListBox item?

Posted 11 May 2013 - 04:00 AM

Hi,
If you take a look at the ListBox.SelectedIndex you will see that it returns an integer that is the index number of the SelectedItem in the listbox. Then Notice that the InputBox where you have (SelectedIndex) should be a string. Try using the SelectedItem.ToString there. As for the line to replace the text with (output) you will need to use something like ListBox.Items(ListBox.SelectedIndex) = output. That will set the text of the listbox item at the selected index. B)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1