Getting Output


In this section, we will be creating output using Windows Forms. Output is basically just getting your program to do something. Like a button that shows some text or some text that changes color if you click on it. For now, we will make a button. First and foremost, you need to create a new file. Go back to the file creation window from the last section and select the “Windows Form” option. After that, make an appropriate name for you form, if you can’t think of a name just label it “output”. Select the destination and hit OK.



Once you have the program opened, you’ll see that a form will come up. That is the GUI of your program, and is where the user will see and communicate with. Go to “View” next to the edit dropdown and select the toolbox. What we need to do first off is place our objects. Type in the toolbox “button”, when you see it, click and drag it on to the form wherever you like, somewhere your user will see it perferably. Once you have your button positioned, go back to the toolbox and type in label. Click and drag it onto the form as well and place it where the user will be able to read it.



Now that you have your objects on the form, we need to change a few options. Firstly, we need to give our label a name so we can remember it easier. If you don’t know what to call the label, just name it “lblOutput”. Using the properties window you can change various options such as: colours, button text, position and size.



After you’ve done that, create a click event by double clicking the button on your form. That should bring you to the coding tab. You need to type inside the button click event.



Once you are in the click event, type in 'lblOutput.Text = “Hello World!”;'. This will take your text inside the parameters (The quotes), and it will be displayed if the button is clicked.



We are now done! You can now start the form up by pressing F5, or by click start at the top of the page. You should see your button, and when you click on it, it will display “Hello World!”. You’ve created output, nice!



On the next section of this guide, I will explain different variables you can use to make your program smarter and more useful.