Date: Thu, 27 Jul 2006 17:26:01 -0500 (CDT) From: Mark Jacobson To: 810-030-01@uni.edu Subject: Part Three Study Guide... Hi VB students, Here is the last portion of the study guide for the final exam... 18. Be able to use a cbo ComboBox or a lst ListBox and its Items() collection with a For Next loop.... Example: Write the code to place all of the contents of array colors() into cboColors ComboBox. Assume that there are 10 colors stored in the colors() array, i.e. Dim colors(10) As String ANSWER: for i as integer = 1 to 10 cboColors.Items.Add( colors(i) ) next i 19. Be able to modify some code to do slightly different pattern, such as the example I gave you yesterday in class where you had the code to do some squares, and I wanted you to modify it to do rectangles that were 3 times as wide as they were tall. You will be given the code for any graphics and would just have to modify it and adapt it for different output. Here is the solution to yesterday's (after you modify it to do rectangles instead of squares, by using 3 * i, etc.. Private Sub Form1_Click( sender... , e... ) Handles Me.Click Dim draw As System.Drawing.Graphics Dim rect As Rectangle Dim brush As SolidBrush draw = Me.CreateGraphics brush = New SolidBrush(Color.Purple) rect = New Rectangle(0, 0, 10, 10) For i As Integer = 5 To 100 Step 5 rect.Width = 3 * i <--------------- 3 times i rect.Height = i draw.FillRectangle(brush, rect) brush.Color = Color.FromArgb(Rnd() * 255, Rnd() * 255, Rnd() * 255) rect.X = rect.X + 3 * i <--------------- 3 times i rect.Y = rect.Y + i Next End Sub 20. Global versus Local variables. Do not worry about Static variables (see previous study guide for midterm). ------ What I call Global variables are also called Form level variables. They are declared outside of any Sub or Function, usually at the beginning of the entire Form or Class code. They are available to ALL of the functions and subs. 21. WebBrowser control. .Navigate() method .Navigated() method .DocumentTitle property 22. Know the difference between ByRef and ByVal for parameters with Functions or with Subs. Sub SwapHasABug(ByVal x as Integer, ByVal y As Integer) Dim temp As Integer temp = x x = y y = temp End Sub What is wrong with the ABOVE SwapHasABug() procedure???? Explain why it won't work and draw a picture if that helps to explain the difference between passing arguments By Value and passing arguments By Reference. -- --- -- --- Correct it and rename it SwapOK() please: SwapOK ANSWER: Sub SwapOK(ByRef x as Integer, ByRef y As Integer) Dim temp As Integer temp = x x = y y = temp End Sub END OF STUDY GUIDE - be sure to look at Part I and Part II too!!! See you at the final exam. Mark