Maybe I am not coding something right... I am new to VB.NET, most of my experience is in VBA and VB6.
cmbX is a combobox passed from my load event of the form. The cmbTax is already drawn on the form... can I not pass it byRef to a class? Do I need to do something different with cmbX after it is passed to UpdateTaxProjectionCombobox?
Code:Private Sub frmEntityTemplate_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'This is in my form load event where cmbTax is a combobox that is drawn on my form. Dim TaxProj As New clsTaxEntity TaxProj.UpdateTaxProjectionCombobox(cmbTax) End Sub Public Sub UpdateTaxProjectionCombobox(ByRef cmbX As ComboBox) Try 'I updated the code per your comments. Dim desc As New List(Of clsComboTag) Dim rsTax As New clsSQLData cmbX.Items.Clear() rsTax.ExecuteQuery("SELECT projection_year , tax_desc , ktax FROM tax_projection ORDER BY Projection_year") For Each drTax As DataRow In rsTax.sqlDataSet.Tables(0).Rows desc.Add(New clsComboTag(String.Format("{0} {1}", drTax("projection_year").ToString.PadRight(10), drTax("tax_desc")), drTax("ktax").ToString)) Next cmbX.DisplayMember = "Description" cmbX.ValueMember = "Value" cmbX.DataSource = desc rsTax = Nothing Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation) End Try End Sub




Reply With Quote