Machine Problem Visual Basic

Only available on StudyMode
  • Download(s) : 96
  • Published : September 29, 2012
Open Document
Text Preview

Format:

Font Style/Size: Calibri – 12
Margins: Normal
Size: Legal 8.5” x 14”
Header and Footer : (same as this document)

Part 1: Source Code

*Use 2 Columns for the Source Code

Part 2: Screen Shoots

Note: This Machine Problem is compose of four problems .Just copy and paste your source code on a word document then print the screen shots after to show the output. Save your work on a rewritable CD. Submit your work with a long brown envelope.

Problem 1: “ The Name Game”

The name game takes a string as input (your name) and searches through it for various tidbits of information. It can tell you your first name and last name and how many characters your name have.

Sample Output:

Criteria:
1. First name must be entered first followed by the last name and must be separated using the space. 2. The output must be displayed using a message box. It will ask you if you want to try again. If yes , the textbox must be cleared the new input and if not the program will just simply end 3. The output name must be in upper case when displayed in the message box.

Thoughts to guide you:

Function Example
Left Left(“Visual Basic”, 4) results in “Visu”
Right Right(“Visual Basic”, 3) results in “sic”
Mid Mid(“2/24/72”, 3, 2) results in “24”
UCase UCase(“Number 7”) results in “NUMBER 7”
Trim Trim(“ Bob Jones “) results in “Bob Jones”
Len Len(“February”) results in 8
InStr InStr(“Visual Basic”, “Bas”) results in 8ON STRING AND STRING-RELATED NUMERIC FUNCTIONS
Notice that I use double quotes when directly inserting a string into one of these functions. They are required unless you are using string variables. Also note that these functions do not take the same number of parameters or arguments. Some of the functions require only one argument, and others require two or three. Here’s what each of these functions is doing and what is required for their operation to be successful:

• The Left function pulls out a string from an input string starting from the left side of the input string. It takes two parameters: One is the input string that you want to search through, and the other is how far you want the function to go or stop when deriving an output string.

• The Right function is similar to the Left function, except it starts searching through the input string starting from the right side. It also takes two parameters as input.

• The Mid function can pull out a string from anywhere in an input string. It takes three parameters as input. The first parameter is the string you want to search through. The second parameter is the starting position of where you want to search. And the last parameter is how far you want to go from the starting position.

• UCase is commonly used in validating user input. It makes any lowercase letters uppercase. It takes only one string as a parameter.

• The Trim function cuts off any spaces that precede or trail a string. But it does not remove spaces within a string. It takes one string as a parameter.

• The Len function is a string-related numeric function. It can tell you how many characters are contained in any given string (including spaces). It takes only one string as its parameter and returns an integer (the number of characters found in the string).

• InStr is another string-related numeric function. It searches through a string and finds the starting position of what you are looking for. It takes two parameters as input. The first parameter is the string you want to search through, and the second parameter is what you want to search for.

The InStr function returns an integer as output (the starting position of the string being searched for). If a match is not found, InStr returns a zero (0). Using one or more of these string functions, you can pull out almost anything you want from a string or text file. This capability is what makes text and...
tracking img