INFS308 - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

INFS308

Description:

Spring 2006. User Types. Programmers can ... dim rate as single. End type. Dim newemp as emprecord. Arrays of Structures. Why create user types (structures) ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 6
Provided by: BenM1
Category:
Tags: infs308

less

Transcript and Presenter's Notes

Title: INFS308


1
INFS308
  • Spring 2006

2
User Types
  • Programmers can create their own variable types
  • One such variable type is a structure
  • How does one reference a portion of the structure?

Type emprecord dim name as string dim id as
integer dim rate as single End type Dim newemp
as emprecord
Name ID Rate
3
Arrays of Structures
  • Why create user types (structures)?
  • Remember that each element must be of the same
    type (e.g. integer, string, etc.)
  • So, how do your store both the name and id number
    of 20 employees in an array?
  • Use the Data structure

4
Arrays of structures
Name id
Type emp dim name as string dim id as
integer End Type Dim emp_array (5) as emp Dim
ind_emp as integer
Bob 24 James
14 Becky 35 Bobbie
45 Zachery 50 Aaron 73
0 1 2 3 4 5
How do you refer to Bobs name? Where is Bobbies
id? What value is in emp_array(4).id Write the
code to go through the array and find Zacherys
id!
5
In Class Exercise
  • Create a record structure, Food_price, and a
    single dimensional array, food_array. Now create
    the user interface to accept text input from the
    user, txtFoodIn, and find and display the price
    of that food item.
  • Structure Food_price
  • Public fooditem as String
  • Public foodprice as decimal
  • End Structure
Write a Comment
User Comments (0)
About PowerShow.com