IMPORTANT NOTICE: As of 21 February, anything posted in this community WILL NOT BE MIGRATED to our new community site. We have pulled all user information and data from this site and are now in an approximately week long process of importing users, roles, and data to our new site. We are leaving this site open and active so you can post and hopefully get a response until the migration is complete. Once complete, the URL that currently takes you to this site will take you to our new site so your bookmarks will work as always. Please read the information on a New Login Process
Getting Started with Visual COBOL for Visual Studio
Hello World using .NET
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")
Now press F5 to run your application or choose Debug->Start Debugging from the menu
Congratulations, your first hello world app in .NET!