# LAB3 - LAB 3(CONDITIONS AND LOOPS 1 Do the handout...

This preview shows pages 1–3. Sign up to view the full content.

1 LAB 3 (CONDITIONS AND LOOPS) 1. Do the handout problems (on this and following pages). 2. Do the debugging examples 3. Make them do problems 1, 3, 4, 11, and 12 from the homework. Test Problem-1: Understanding simple IF-THEN-ELSE condition Problem Statement : Develop an advanced version of area calculator that will compute the area (as described above) and in addition it will also let the user know whether the object he is dealing with is a rectangle or a square. Area Calculator-Ver2 Length (m) 2.100 Width (m) 4.000 Area (m^2) Object Type Set up a command button and enter the following code: Option Explicit Option Base 1 Private Sub Mycode_Click() Dim Length As Single, Width As Single, Area As Single Length = Cells(2, 2) Width = Cells(3, 2) Area = Length * Width Cells(4, 2) = Area If Length = Width Then Cells(5, 2) = "Square" Else Cells(5, 2) = "Rectangle" End If End Sub Exit the design mode and run the code. You will see that your spreadsheet will be updated with the data shown below: Area Calculator-Ver2 Length (m) 2.100 Width (m) 4.000 Area (m^2) 8.400 Object Type Rectangle Also, Area Calculator-Ver2 Length (m) 2.100 Width (m) 2.100 Area (m^2) 4.410 Object Type Square

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 This program is almost identical to the previous program, except you used if-then-endif structure to make a decision on the type of object you are dealing with it. Note: It is always important to use proper indentation when you use IF and For-next conditions. It is easy to use Tab for this purpose. However, the default for tab is 4 spaces, but you can change this to two spaces by using Tools, options, Editor tab and change Tab Width to 2.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/14/2011 for the course CE 3010 taught by Professor Clement during the Fall '09 term at Auburn University.

### Page1 / 5

LAB3 - LAB 3(CONDITIONS AND LOOPS 1 Do the handout...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online