>Thanks again but what do i declare colValue as and datatable in order to get the expected output.
Answer is
Object type.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("No", GetType(Int32))
dt.Columns.Add("Name")
dt.Rows.Add(1, "A")
dt.Rows.Add(2, "B")
dt.Rows.Add(3, "C")
For Each r As DataRow In dt.Rows
ListBox1.Items.Add(r("No"))
Next
End Sub
Anothe code - DataSource bind
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("No", GetType(Int32))
dt.Columns.Add("Name")
dt.Rows.Add(1, "A")
dt.Rows.Add(2, "B")
dt.Rows.Add(3, "C")
ListBox1.DataSource = dt
ListBox1.DisplayMember = "Name"
ListBox1.ValueMember = "No"
End Sub
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
Offline 6,527 posts
since Oct 2008