I've seen this, this, and this, but they don't quite answer my question.
I have a project that is an upgrade of a VB6 program to VB.NET (2008) on the way to an eventual upgrade to today's version. I have a module that does a variety of things for many forms. The name of the active form is stored in a global variable (Current_Active_Form
). There are the same controls on many forms with the same name from form to form (comboX
, for instance). The one I am concerned with now is a function that loads a combobox (comboX
) with a list of items using a for loop. There are many other functions that do this with many other comboboxes and datagridviews, so this will help me all over the place.
Example:
Public Function fillComboX(ByRef fncString As Object) As String
'Current_Active_Form is a global variable
Dim startPoint as Integer 'substring starting point
Dim items as Integer 'number of items in item string
Dim strItem as String 'string for individual item
dim strItems as String 'string for all items
...'code that fills strItems based on fncString
'(don't ask me why it's an object)
...'items is filled at the same time
startPoint = 1
With Current_Active_Form
.comboX.Items.Add("")
'^^ line gives error comboX is not a member of System.Windows.Forms.Form
For i = 1 to items
strItem = strItems.Substring(startPoint, 50)
.comboX.Items.Add(strItem)
'^^so does this line
startPoint = startPoint + 50
Next i
End With
End Function
Is there a way to do this similar to how I it have here? I can make whatever changes I need to, but this is a big enough upgrade as is. Thanks!