Converting listbox items to a string.

  • Thread starter Thread starter jazFunk
  • Start date Start date
  • Tags Tags
    String
AI Thread Summary
The discussion revolves around the challenge of converting items from a ListBox to a single string in VB (Visual Basic). The original poster struggles with the task, initially attempting to use the ListBox's items but encountering errors. A suggestion is made to use the syntax Str(List1.List(x)), but this does not resolve the issue. The poster also tries to convert the items using the ToString method, which fails to concatenate the items into one string. A working solution is eventually provided, where a loop is used to concatenate the items from the ListBox into a single string, successfully achieving the desired outcome. This method involves iterating through the ListBox items and appending them to a label's caption.
jazFunk
Messages
12
Reaction score
0
It seems like it would be a fairly simple task, yet I have been unable to complete this task.
 
Technology news on Phys.org
jazFunk said:
It seems like it would be a fairly simple task, yet I have been unable to complete this task.

what language are you using?
 
I'm using VB.
 
try with Str(List1.List(x))
where x = the item # you want. Remember it starts from 0
 
That didn't work either. The error was that 'List is not a member of the 'Systems.Windows.Forms.ListBox'.

I try this with no error but it's not converting the items to a single string:

Dim OrigString As String = Me.lstLegend.Items.ToString()

Essentially I need to convert all of the items in a list box to a single string which can then be processed through a function.

Thanks, in advance.
 
Private Sub Command1_Click()

For x = 0 To 2
Label1.Caption = Label1.Caption & CStr(List1.List(x))
Next x

End Sub

That worked perfectly for me, try it. I had 3 items in my List.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top