problem with a function

kriwie

New member
Joined
Aug 11, 2004
Messages
2
Programming Experience
1-3
Hi all,


I've a little, but very annoying problem with a function.
This is what I have:

The program starts with the MainFrame.
In the MainFrame starts another frame with this code:

Dim form As New Pictureform
form.MdiParent = Me
form.Show()

In the MainFrame there is a function that I also want to use in the form "Pictureform". The function is public, so this is not the problem:


Public Sub startscan()
...
End Sub


The code in Pictureform to execute the function is the problem:


Private Sub btnOpnieuw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpnieuw.Click
MainFrame.startscannen()
End Sub

MainFrame is also Public.
"MainFrame is not declared", can someone help me?

Thanks in advance

 
I'm finding this a little confusing. Is MainFrame.StartScan in the same class as the rest if not the just because you have made a routine public it doesn't mean you can access it directly. You need an instance of the class it occupies, unless it is a shared member.
 
if its a function wouldn't you be passing it something?
 
Yes, as vis781 told you ... you suppose you use it as a shared member. Something like this:
VB.NET:
[COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Shared [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2][COLOR=#000000] startScan()[/COLOR]
[/SIZE][SIZE=2][COLOR=#008000]'......
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][/COLOR]
Now you can access it from all over ... just call the routine ;)
Btw, why you keep the certain routine inside mainFrame form class. I would move it inside class file or module instead ....
Regards ;)
 
Back
Top