Computer Programming

Computer Programming » An Actual Computer Program » Adding a Welcome Message

Adding a Welcome Message

Select the label tool from the toolbox. We are using a label as that is the means by which we can put some text on our form. Traditionally, a label is used next to an input area to identify what is supposed to go into the input. Without an input area near it, it acts like a bit of text on the form.


Double click on it and it will appear in the form window. The double click is one way to put one of the items from the toolbox onto our Form. We could also have clicked on the label and then dragged it from the toolbox onto our form.


In the properties, find the text property, which now says Label1. The Label1 is the default value that is given to the label. Similar to the form, the label has a text property, only this time instead of changing the title it changes the text displayed within the label area. If we wanted to change what is displayed in the label from within our code, say when we press a button, we would need to remember the name of the item that we want to change. For us, there are not many items to worry about, but when you have lots of them you do want to rename these items to be something more memorable so that you do not have to look it up each time you want to do something with it.


Change the text property to be Welcome to Craps!. Notice that you will not be able to see the whole line of text that you entered. This is a good time to point out that what were are entering is data. While much of visual basic programming lets you see exactly what you are going to get, there is another side in which you make changes and only when everything comes togeter do you see the finished product.


You can see the information in the label has been changed to be Welcome to Craps! The label is like a read-only text box. We certainly want to make our title to be read-only as we do not want to let our users be able to change what it says.


Go to the font property because we want to make our welcome message a little bigger. To change the size of the text displayed, we change the size of the font that is used to display the text. The text property contains the data that is to be displayed, and the font will specify how the text will be displayed.


There is a little triangle. It means there are more things there. Click the triangle to see the other items. If you click the triangle again, it will roll up all those extra things into the summary. Click it again to display. Click it again to roll it back up.


We are going to change the size of the letter. For now it is 8.5. If you are familiar with a word processor application, you may think that that is a small font size, as when writing a letter people will typically use a 12 point font size. On the computer screen, a smaller font size is typical.


Change it to 24. That should be a big size that we can use for a title.


The banner now fills the whole window. You can adjust the size to be other than 24. You may want to move it to the center if you make it smaller. It is your program so you can experiment to make it be what you like.


Run the program. Right now it is not much of a program, but a good habit to get into is to run the program after adding in features just to be sure that you have what you are expecting. It is easier to change a feature just after you add it rather than later on.


⇐ Prev Chapter
Writing a dice game of craps

Next Chapter ⇒
Adding button to play game

Computer Programming for Everyday People
Michael Bigrigg

Amazon eBook

Powered by w3.css