Link to home
Start Free TrialLog in
Avatar of 5thcav
5thcavFlag for United States of America

asked on

Open Another form and close itself - Fix EE answer

This is a repair or help with the EE solution link below

adding this line to the forms returns these errors
Public Event switchTo(ByVal sender As Form, ByVal SlideShowWindow As MyForms)

MainForm.vb(6): 'MainForm' cannot expose a Friend type outside of the Public class 'MainForm'.
Or
MainForm.vb(34): 'MainForm' cannot expose a Friend type outside of the Public class 'MainForm'.

TIA

https://www.experts-exchange.com/questions/21185658/Open-Another-form-and-close-itself.html
SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have tried it and it does not make a difference. :-(
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think they all have to be the same...either all Public or all Friend.
I had them all Public but it was not working. It only started working when I changed the two to friend.
Avatar of 5thcav

ASKER

Bummer i have to retype my speech,, (didnt get posted?)

It was a tuff call, you did a lot of work Idle_Mind but FernandoSoto had his coffee this morning and did answer the question at hand..

I’ll try and work this back into my code, I took another route. I’ll take your word on it working (Kind of like saying Sure I do love you or the check is in the mail, :) ) and put it into a test solution for future reference.

Thanks for the Help!
Whatever works for you guys....all I can say is I developed the solution on my machine from scracth and it works with Public for me!

=)
Avatar of 5thcav

ASKER

ya, right what ever you say...

No really,,, I I'll make a new project ASAP and test both, and come back here and kiss some A#! is youre right
Avatar of 5thcav

ASKER

There was never a  Friend Enum MyForms

It was always

Public Enum MyForms
        formA = 0
        formB = 1
End Enum

You stated:

Try changing this:
    Friend Enum MyForms
to
    Public Enum MyForms

and see if that makes a difference.

I changed it to:

    Friend Enum MyForms
        formA = 0
        formB = 1
    End Enum

And still had \FormB.vb(56): 'formName' cannot expose a Friend type outside of the Public class 'FormB'.
I changed it back to Public Enum MyForms and added Friend keyword to FormA and B and it works like a charm,,,
Dot no what to say,, I really do appreciate all your work this is a really nice bit of code to have.

We all know computers and software work under Murphy’s law!

Thanks

Ray
Glad you got it to work...
Hi 5thcav & Idle_Mind;

This issue has been eating away at me. So I had to research it for a proper solution. This is what I found. When I created the MyApplication Module in Visual Studio .Net, I went to the Solution Explorer Window and did a Add->Add Module… This places the Module MyApplication and End Module statements in the new code window. I cut and past the code for the EE web page. The problem is when there is no access modifier assigned to the Module the default is Friend. Then when the code in FormA and FormB were created and the line of code was placed in it for Public Event switchTo(ByVal sender As Form, ByVal formName As MyForms) caused the problem 'formName' cannot expose a Friend type outside of the Public class 'FormB'. It is illegal to add such a public member to the FormA and FormB class that relies on the MyApplication module, because a class user would have access to the field but not to its underlying type. That is why the statement RaiseEvent switchTo(Me, MyApplication.MyForms.formB) did not cause a problem because MyApplication.MyForms.formB accessed the field which is OK. I assume that   5thcav  did the same thing I did to have the same problem. So placing the access modifier Public in front of the Module MyApplication would fix the problem as Idle_Mind has in his original code. Great job Idle_Mind :-)

Fernando