prav_roy
Well-known member
hi,
i have a class in that i have a function which takes two args, one is string other one is listbox, i am using to fill my listbox, i am calling this function from different form..
my query is that, can i use same function to pass my other controls like combobox etc by changing second args as control.. if so then how can i do it..
PublicFunction Reader(ByVal str AsString, ByVal lst As Control)
i have a class in that i have a function which takes two args, one is string other one is listbox, i am using to fill my listbox, i am calling this function from different form..
VB.NET:
Public Sub Reader(ByVal str As String, ByVal lst As ListBox)
Dim cmd As New SqlCommand()
Dim dr As New SqlDataAdapter()
Dim ds As New DataSet()
cmd.Connection = dbcon
cmd.CommandText = str
dr.SelectCommand = cmd
Try
dr.Fill(ds)
With lst
.DataSource = ds.Tables(0)
.DisplayMember = "itemname"
.ValueMember = "itemno"
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
Finally
dr = Nothing
ds = Nothing
End Try
End Sub
my query is that, can i use same function to pass my other controls like combobox etc by changing second args as control.. if so then how can i do it..
PublicFunction Reader(ByVal str AsString, ByVal lst As Control)
Last edited by a moderator: