Web.stonehill.edu



Homework #2 - Solution

1) Page 181.

1. B. Text typed in a textbox is stored in the Text property.

txtMyText.Text = “Hello there”

2. A. & is used to concatenate strings.

txtMyText.Text = “Hello” & “ there”

3. D. Focus is the method that is used to set the focus to a particular control.

txtMyText.Focus()

4. B. The AcceptButton property on the form allows you to specify which Sub is called if the user enters a Return in a textbox.

5. C. The CancelButton property on the form allows you to specify which Sub is called if the user enters an Esc in a textbox.

6. A. The TabIndex property allows you to order controls on a form so you can tab among the controls.

7. D. You can specify the access key for a button by setting the text property properly.

txtMyText.Text = “&My button”

8. C. You use the Text property to set the title for Group boxes.

grpTest.Text = “My Group Box”

9. B. Constants are always declared with the Const keyword.

Const intLoop As Integer = 4

10. D. This one gave most people some trouble. The only one of these four that is a section in your program is the Module. Scope (Choice C) is close – The scope of the variable declared is the module.

11. B. This is a bit tricky too. The “N3” formatter causes ToString to format the string as a number with 3 significant digits. However, these digits are rounded at the least significant digit. Since the 4th digit is > 5, the number is rounded. Not sure? Try it in code!

12. None. This question is just plain wrong, so I’m not going to count this off. If you’re not sure of the answer, you can always program it. The actual real answer is: “” (which wasn’t given. The closest answer is “C”, but even that’s not 100% correct. Sorry that they have an error in the text!!

2) Bonus. The foreColor property sets the color of the text that is shown in the textbox. The backColor property sets the background color for the text. If you set both of them to the same value, you will see a solid block of color and won’t be able to see the text!! Not sure – just try it!

3) Trivia. Several of you got this (did you google it??). John Scott Harrison is the only man in US history who was both son and father of a US President!! (His father was William Henry Harrison and his son was Benjamin Harrison.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download