1.19 - Strings and Stories
program will allow the user to enter in a number of words that your program
will store into variables, and then use in a story.
You must first think of some type of story that you will tell, and then decide which words you will let the user chose. This may take some time. When you know the words the user will chose, create a form that resembles the following (your prompts will be different than the ones in this example):
2... When the user clicks on the DISPLAY STORY button, your program will display a new form, with the whole story written out, including the words entered by the user. To create a new form, click on the Add New Item button in the top left of the screen, it should look like this: . Then select Add Windows Form and then click on Add.
3... You can jump between the two forms by clicking on either Form1 or Form2 on the right of your screen:
4... You should now click on the top of Form2 and then change the name of the form to frmStory. Now insert a label into form two. Change the AutoSize property to False and then resize the label so that it takes up the whole form. It should resemble the following:
5... Now go back to Form1
and double click on the DISPLAY STORY button. The code for
this button will simply show the second form, the code is:
6... You must now enter the code necessary to store the variables and then display them onto the second form. To store all of the user's entries into variables you should use code similar to strName = txtName.Text. You will need to declare variables and enter lines of code like this for all of the text boxes on your forms.
7... In the second form, you will need to enter code to display the story in the label. This story will display whenever the form is loaded. To have this happen, click anywhere on the form, but away from the blank label. This will allow you to enter code inside the frmStory_Load operation. Your code will resemble something like the following:
8... Make sure your story makes sense. You will have to make sure you have spaces in all the correct spaces, and that the story makes sense. Be careful with males and females, you may need if statements to determine the correct pronouns to use (he, she, him, her).