INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ListBox issue in VB2010

ListBox issue in VB2010

(OP)
Hi All

I am using a listbox and want to display a variable arrays value in listbox.

CODE --> vb2010

Public InputHistorypoint(256), Perameter(0-600) As String
Dim b as integer
Public addrs, InputNO as integer


    For b = 0 To InputNO - 1
        InputHistorypoint(b) = Perameter((addrs + 4) + b)
        lstHistoryPoint.Items.Add(InputHistorypoint(b))
    Next 

Please see the attachment
It display: -

ListViewItem:{Input-1}

ListViewItem:{Input-2}

ListViewItem:{Input-3}

ListViewItem:{Input-4}

ListViewItem:{Input-5}

ListViewItem:{Input-6}

Actual value of variable are under {}. It's Displaying "ListViewItem:" extra text. I think it's property configuration mistake.

Please help me

RE: ListBox issue in VB2010

In some places (at work) we cannot download attached file.

What are you passing in the array named Perameter?
Could you give an example of what's in it?
And what you expect to see in the lstHistoryPoint listbox?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: ListBox issue in VB2010

(OP)
1,2.

Quote (What are you passing in the array named Perameter?)


Variable 'Perameter' is a Public variable. When I open a file total values saves in 'Perameter'(array).

Perameter(0) = "Input-1"
Perameter(1) = "Input-2"
Perameter(2) = "Input-3"
Perameter(3) = "Input-4"
Perameter(4) = "Input-5"
Perameter(5) = "Input-6"

CODE --> VB2010

InputHistorypoint(b) = Perameter((addrs + 4) + b) 
I am saving 'Perameter' arrays value in 'InputHistorypoint' arrays

CODE --> VB2010

lstHistoryPoint.Items.Add(InputHistorypoint(b)) 
and adding in listbox 'lstHistoryPoint'

3.

Quote (And what you expect to see in the lstHistoryPoint listbox?)


I want to see: -

Input-1
Input-2
Input-3
Input-4
Input-5
Input-6


But It's sowing: -

ListViewItem:{Input-1}
ListViewItem:{Input-2}
ListViewItem:{Input-3}
ListViewItem:{Input-4}
ListViewItem:{Input-5}
ListViewItem:{Input-6}

Adding "ListViewItem:{}" extra text .

RE: ListBox issue in VB2010

This will give you what you want (I hope):

CODE

Private Sub Button1_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Button1.Click

        Dim Perameter(0 To 600) As String

        Perameter(0) = "Input-1"
        Perameter(1) = "Input-2"
        Perameter(2) = "Input-3"
        Perameter(3) = "Input-4"
        Perameter(4) = "Input-5"
        Perameter(5) = "Input-6"

        With lstHistoryPoint
            .Items.Clear()
            For i = 0 To Perameter.Length - 1
                If Len(Perameter(i)) > 0 Then
                    .Items.Add(Perameter(i))
                End If
            Next i
        End With

    End Sub 

"I am saving 'Perameter' arrays value in 'InputHistorypoint' arrays"
Why?
Personally I don’t like to 'juggle' data between different data storage.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: ListBox issue in VB2010

(OP)
I'm sorry It was my mistake. When I was putting data in 'Perameter' variable. I was using

CODE -->

Perameter(i) = lstPoints.Items(i).ToString 

I change it with

CODE -->

Perameter(i) = lstPoints.Items(i).SubItems(0).Text 


It's working fine
Thank you for your valuable advices.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close