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!
#HowTo-BestPractice







