All posts by Mr Stratton

Computing teacher and a PT at Coltness High School.

Computer Structure – Main Memory

OK I may have went a little overboard on EEPROM 🙂 but it is very very useful. Some of you might think that EEPROM and flash memory is the same thing but you would be wrong. Have a look at this from webopedia

Pronounced double-ee-prom or e-e-prom, short for electrically erasableprogrammable read-only memory. EEPROM is a special type of PROM that can be erased by exposing it to an electrical charge. Like other types of PROM, EEPROM retains its contents even when the power is turned off. Also like other types of ROM, EEPROM is not as fast as RAM.

EEPROM is similar to flash memory (sometimes called flash EEPROM). The principal difference is that EEPROM requires data to be written or erased onebyte at a time whereas flash memory allows data to be written or erased inblocks. This makes flash memory faster.

Select Case

The  Select..Case statement is a special instance of the IF  structure. To implement multi-way decisions the  statement provides a more concise and elegant representation than multiple and statements, which can get very difficult to follow. Probably if you have more than three conditional statements you should consider using the Select..Case statement instead.

Here is an example algorithm

  1. Ask user to input a number between 1 and 7
  2. select case number
  3. Case is = 1 Display “Sunday”
  4. Case is = 2 Display “Monday”
  5. Case is = 3 Display “Tuesday”
  6. Case is = 4 Display “Wednesday”
  7. Case is = 5 Display “Thursday”
  8. Case is = 6 Display “Friday”
  9. Case is = 7 Display “Saturday”
  10. Case else Display “Error”
  11. End Select

String Handling

Description and exemplification of the following constructs in pseudocode and an appropriate high level language: string operations (concatenation and substrings)

String and string handling are the bread and butter of all programs.  Today we looked at how the programmer can cut (substring) and paste (concatenation) strings together.

  • Len – Output is the length of the string
  • Ucase – Output is the string in upper case
  • Lcase – Output is the string in lower case
  • Asc – Output is the ASCII value of the character
  • Chr – Output is the ASCII character of the value
  • Mid$ – outputs the characters from anypoint in the string.
    • Mid$(String,First,HowMany)
  • Strings.Left – Outputs the leftmost characters in a string.
    • Strings.Left(String,HowMany)
  • Strings.Right – Outputs the rightmost characters in a string.
    • Strings.Right(String,HowMany)

Concatenation is a scary-looking word, but it simply means “joining together”.  String concatenation means joining two (or more) strings together to form one new string: String concatenation in VB is very simple – you don’t need a special function – you just use the + sign.

For example,

  • if string1 = “Fred”,
  • and string2 = “McSporran”,
  • then string1 + string2 = “FredMcSporran”.

Today’s “Impossible Task”

Create a program that displays the ASCii codes of all the characters of a string that is entered by the user, solution after the jump.

Continue reading String Handling

Simple Conditional Statements (IF)

A simple conditional statement is checks one condition. We use IF in VB, it is written as

  • IF <Condition> then
    • Do something
  • ELSE
    • Do something else
  • END IF

The Condition has to resolve to true or false and uses comparison operators (Comparitors). Try these tasks

  1. Says hello to people named Bob
  2. Tells you if a number is above 10
  3. Tells you which of two numbers is the biggest
  4. Tells you if a number is odd or even

Continue reading Simple Conditional Statements (IF)