Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Getting Started with Visual COBOL for Visual Studio

Getting Started with Visual COBOL for Visual Studio

Getting Started with Visual COBOL for Visual Studio

Hello World using .NET

Summary

This getting started tutorial shows how you can create a user interface using .NET and call a COBOL application to perform the backend processing. 


Start Visual Studio and create a new project from the File -> New menu

Make sure the COBOL  section is selected and from there choose Windows Forms Application 

Name the project and choose a location for it to be stored and then click OK.


 Your screen should look similar to this.

 

We’re going to paint a very simple user interface with a single button.

To add the button, make sure the toolbox is visible from the view menu:

 

 

Now you can drag a button from toolbox to the WinForm

 

 

Right click the button and choose properties

  

In the properties window, change the value of the button’s Text property to “Click Me”.


You can change other properties if you like, including color.

Now double click the button to add an event handler, your screen should now look like this.

 

This is object oriented COBOL and the buton1_click method will get invoked every time the button is clicked. We could call an existing procedural COBOL program from this point but we’re just going to display a message box.

Add the following code to the button1_Click Method:

 

method-id button1_Click final private.

procedure division using by value sender as object e as type System.EventArgs.        

          invoke type MessageBox::Show("Hello World")

 end method.

      

Now press F5 to run your application or choose Debug->Start Debugging from the menu

  

Congratulations, your first hello world app in .NET!

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Version history
Revision #:
1 of 1
Last update:
‎2012-12-14 06:10
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.