Assignment
5
 
Objective:  To
learn the usage of loop statements in programming.
 
A) Hangman contd.
Upgrade the hangman program in
assignment 4 to allow the chosen word to have more than 1 occurrence of a
character (eg CREATE which has 2 occurrences of E should be allowed). If the
user enters a character that appears more than once in the word then the displayedWord
should display all
occurrences of the character entered by the user on a single  click of the SUBMIT button.
 
The following example
demonstrates this change in the working(assuming the word
is “CREATE):
1.   The user
enters the character ‘E’ and clicks SUBMIT.
2. 
The new displayedWord is “--E--E”.
 
Functions and
Variables
1.  Mid(String,
Starting position, Optional Lengh)
2.   dim nextPos as Integer is used to find the occurrences
of a character after the first occurrence in word.
 
 
B) Times Table
 
 
| Object type | Name  | Function | 
| Label | LblOf | Dsplays the string “Table of” | 
| Label  | LblTo | Displays the string “Table up to” | 
| Textbox | TxtOf | Takes the user input for the integer for which the table
  is to be computed. (I1) | 
| Textbox | TxtTo | Takes the user input for the integer up to which the
  table is to be computed. (I2) | 
| Button | BtnSubmit | On click, it causes the times table of I1 up to I2 to be
  computed. | 
| Label | LblTable | Displays the table. | 
 
Working
1.   The user
enters input 1 for which the times table is to be computed (I1).
2.   The user
enters the input 2 (I2) up to which the table for I1 is to be computed.
3.   The user
clicks submit.
4.   The program
displays the times table of I1 from 1 to I2.
 
Constructs Used
1.   For
loop: It runs from 1 to I2, calculates the times table for I1 from 1 to I2
and displays it onto lblTable
2.    vbNewLine : when concatenated with a
string it causes any display after it to begin from the next line. The form of
display we require is: