0

I'm self taught so pardon me if my terminoligy isn't correct.

I want to call a sub within another sub that is in a completely different form. but for some reason i can't get it to work. Maybe it's not possible. I'm not sure.

for a bit of background on the program. There's two pictureboxes. One has a binding source and the other does not. I want the one that doesnt have a binding source to display the same image as the other picture box once it has loaded.

so the first sub is in form2. code is as follows:

Public Sub GetImage()
    Me.Pbox_Image.Image = Mainfrm.Pbox_Image.Image
    Me.Pbox_Image.Refresh()
    Me.Pbox_Image.Update()
End Sub

This procedure works fine when called within form2. But i want the code to run when mainfrm p_Imageload is completed.

The code I used in mainfrm is as follows:

Public Sub Patient_Image_LoadCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles Patient_Image.LoadCompleted
    GetImage()
End Sub

Visual studio displays an error and the code will not run. The error says that GetImage is not declared. I thought setting it to public would solve the issue but it didn't.

Any help is greatly appreciated.

1 Answers1

2

You call it with adding a containing class infront of method, like this:

On FormX:

Sub
    FormY.MethodZ()
End Sub
CruleD
  • 1,153
  • 2
  • 7
  • 15