fumei
07-27-2010, 01:05 PM
After six years of teaching my Word VBA course I have finally had a student come up with the bonus points for an exercise I give them.
Lab Exercise:
Write a procedure that will write out each cell of each table (identified by its Row/Column) and include the text for that cell. Include leading text identifying each table by order in the document.
Example (result should look like this):
Table x has the following contents:
Cell(1,1) = "The first cell"
Cell(1,2) = "The second cell row 1"
Cell(1,3) = "The third column text of row 1."
Cell(2,1) = blank
Cell(2,2) = "The second column of the second row."
Cell(2,3) = "Third column row Two"
Table y has the following contents:
Cell(1,1) = "The quick brown fox"
Cell(1,2) = "crossed the road for a chicken"
Cell(1,3) = "that was simply curious"
Cell(2,1) = "about this side, or was it"
Cell(2,2) = "the other side."
Cell(2,3) = "blank"
Double bonus points for completion using < 10 instructions. Declaration of variables not considered an instruction (even though technically they are).
Triple bonus points for fully error-trapped code that deals with all errors, including merged cell issues. (This is not possible using <10 instructions.)
This student handed in two versions, one <10 instructions, the other fully error-trapped. They then asked if that meant they get double bonus for the one, AND triple for the other, AND was it compounded?
Smart-ass. Actually, very smart. She has never done any programming whatsoever before. Scary.
Oh, and it took her 20 minutes to come up with both versions. Like I said, scary. I do not think I have ever had such a challenging student. I have had my logic butt kicked a couple of times.
Lab Exercise:
Write a procedure that will write out each cell of each table (identified by its Row/Column) and include the text for that cell. Include leading text identifying each table by order in the document.
Example (result should look like this):
Table x has the following contents:
Cell(1,1) = "The first cell"
Cell(1,2) = "The second cell row 1"
Cell(1,3) = "The third column text of row 1."
Cell(2,1) = blank
Cell(2,2) = "The second column of the second row."
Cell(2,3) = "Third column row Two"
Table y has the following contents:
Cell(1,1) = "The quick brown fox"
Cell(1,2) = "crossed the road for a chicken"
Cell(1,3) = "that was simply curious"
Cell(2,1) = "about this side, or was it"
Cell(2,2) = "the other side."
Cell(2,3) = "blank"
Double bonus points for completion using < 10 instructions. Declaration of variables not considered an instruction (even though technically they are).
Triple bonus points for fully error-trapped code that deals with all errors, including merged cell issues. (This is not possible using <10 instructions.)
This student handed in two versions, one <10 instructions, the other fully error-trapped. They then asked if that meant they get double bonus for the one, AND triple for the other, AND was it compounded?
Smart-ass. Actually, very smart. She has never done any programming whatsoever before. Scary.
Oh, and it took her 20 minutes to come up with both versions. Like I said, scary. I do not think I have ever had such a challenging student. I have had my logic butt kicked a couple of times.