Winforms: calling 2nd form

I am working through "Tutorial: Developing .NET Managed COBOL", trying to learn Visual COBOL. 

I developed Form1, then Menu1 and made it my startup program - all fine and working.  Then to extend the exercise I added a button to Menu1 to call Form1  using the cobol command

call "Form1".

but it fails with error "173 Called program file not found in drive/directory [Form1]"

What can I be doing wrong?  Please help!  Surely the syntax is correct, and both forms can be seen in Solution Explorer.

  • Verified Answer

    The call statement is used to execute COBOL procedural programs as subprograms.

    When you want to call a method in a COBOL class such as a Windows Forms class you need to instantiate the class as an object and then invoke its methods using the COBOL invoke statement.

    You might want to take a look at the managed COBOL Concepts section of the docs here:

    Example:

           method-id button1_Click final private.
           01 myform  type testform2.Form2.
           procedure division using by value sender as object e as type System.EventArgs.
               
               set myform to new testform2.Form2
               invoke myform::ShowDialog
    
  • Thank you - that works, and I understand more, so a double win!

  • Chris,

    the link to the docs appears to be broken...

  • Hmmmm.   It appears to be the new 2.3 doc.  Thanks, although I was unable to find the specific Managed-calling-Managed subject matter in the above examples.

  • What is it exactly that you are looking for? The section on Interoperability talks about various calling techniques that can be used to call between native/managed, etc. There are also some tutorials that cover this topic within the knowledgebase.

    Go to the search bar at the top right-hand side of this page and click on the arrow and select Search Visual COBOL. Then enter in the search term:

        call statement

    You should see 5 articles listed under the Wiki category where each article covers a different calling scenario for native and managed combinations.

    Is this what you are looking for?

  • Here is what I found:

    1. this forum article itself in the forum

    2. A wiki titled "Handle multiple WinForm forms in Visual COBOL"

    3. A forum article "using 'Call' in Method

    4. A wiki article "Visual COBOL for Visual Studio Getting Started with Solutions, Projects and the COBOL CALL Statement - Managed" that included a "2433_Visual COBOL Call Managed Tutorial.zip" and some related wiki articles covering other types of mixed calls, etc.

    From these, I gleaned what I needed to know.  Sometimes it isn't very easy to find what you are looking for in the "official" Doc.

    Thanks