'How to refer to the controls of a multi project solution from a module function
I have managed to combine 2 projects in one solution. Project1 is the startup project.
Project1/Button1 opens Form1 of Project2 with the code below:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim frm1ofProject2 As New Project2.Form1
frm1ofProject2.ShowDialog()
End Sub
I have a ComboBox1 control on Form1 of Project2 and I get the selectedindex number of the Combobox with the following code:
Public Function BKS_IMP_Bul()
Dim secilen As Integer
secilen = Form1.ComboBox1.SelectedIndex
End Function
The code above is in a function defined in Module1 of Project2 and it does not work as I expect. It returns a value of secilen=-1 whatever I select from the ComboBox. If I move the code into a button click and change the code to;
secilen = Form1.ComboBox1.SelectedIndex
it works, however it needs to be in that module. I do not know what I am missing so any help would be much appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
