ndavenport
Member
- Joined
- Sep 2, 2009
- Messages
- 8
- Programming Experience
- Beginner
I'm having an issue where I need to pass the value in a variable from one sub to another. Here is the scenario. I have two forms; Main_Form and frmClient. I take a value from frmClient and pass it into a sub called Form_Activate located in Main_Form. I then need to take the value from Form_Activate and use it in a sub called when the user selects a menu item in the toolstrip.
Starting point is frmClient and the code there is this:
Private Sub Button1_Click(ByVal sender as System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Client As Integer
Client = cmbClient.SelectedValue
Main_Form.Form_Activate(Client)
End Sub
The value gets passed to the Main_Form sub names Form_Activate. This is working correctly and the value shows up as expected.
Public Sub Form_Activate(ByVal ClientReceived As Integer)
pintClient = ClientReceived
End Sub
Now here is where I run into the problem. I need to carry the value stored in pintClient to another sub on the form named UpdateDatabaseToolSTripMenuItem. This sub is called when the user clicks a menu item named Update Database.
Private Sub UpdateDatabaseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateDatabaseToolStripMenuItem.Click
'some code
End Sub
If I attempt to use the variable pintClient directly, it has a value of 0 by the time it is called in the UpdateDatabaseToolStripMenuItem_Click Sub.
Starting point is frmClient and the code there is this:
Private Sub Button1_Click(ByVal sender as System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Client As Integer
Client = cmbClient.SelectedValue
Main_Form.Form_Activate(Client)
End Sub
The value gets passed to the Main_Form sub names Form_Activate. This is working correctly and the value shows up as expected.
Public Sub Form_Activate(ByVal ClientReceived As Integer)
pintClient = ClientReceived
End Sub
Now here is where I run into the problem. I need to carry the value stored in pintClient to another sub on the form named UpdateDatabaseToolSTripMenuItem. This sub is called when the user clicks a menu item named Update Database.
Private Sub UpdateDatabaseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateDatabaseToolStripMenuItem.Click
'some code
End Sub
If I attempt to use the variable pintClient directly, it has a value of 0 by the time it is called in the UpdateDatabaseToolStripMenuItem_Click Sub.
Last edited: