FAQ - The Visual Basic Course

Q1. Is Visual Basic Mac Friendly?
A1. Visual Basic is NOT Mac Friendly and cannot be used with a Mac unless you are using something like BootStrap or VirtualBox to run Microsoft Windows 10 with Visual Studio installed. There is a version of Visual Studio that runs directly on Mac/OS, but it does not include Visual Basic.
   
Q2. Does the Visual Basic Course cover VBA?
A2. The Visual Basic course does NOT cover VBA (Visual Basic for Applications) which is a macro scripting language used by Microsoft Office products such as Word, Excel, PowerPoint and Access. There are similarities between Visual Basic and VBA but they should be considered separate languages much like the differences between Java and JavaScript.
   
Q3. Does the Visual Basic Course cover .Net Framework?
A3. The Visual Basic course is an introductory course in computer programming. Although Visual Basic runs on .Net, the course does not cover the .Net Framework. Most of the routines and methods that are in the libraries provided by Microsoft are available to both Visual Basic and C#. This collection of common routines gives Visual Basic much of the capabilities of C#. However in large projects, C# is the preferred language over Visual Basic.
   
Q4. Can the lab assignments be done on a Chromebook?
A4.

A Chromebook is great for browsing the web and using the powerful office suite GoogleDocs. You will be able to use the Chromebook to view the lectures, lab assignments and take the quizzes. However, will not be able to do the lab assignments on a Chromebook. The lab assignments are an essential part of the course and required to pass the class. You need to have Microsoft Windows 10 and Microsoft Visual Studio on a computer in order to do the lab assignments.
 
There are several options that you may want to consider:
1) Get access to a computer that is running Windows 10 and install Visual Studio. Either on a PC or Mac computer.
2) If you are also a student at San Jose State University, see if there is a computer lab you can use that has Visual Studio.
3) Use the Open Lab at San Jose City College. I expect to have a list of available hours by the second week of school.
4) See if SJCC is offering another section of CIS073 Visual Basic Programming that is on campus.
5) Use the Chrome Remote Desktop to login to a computer that turned on all the time, connected to the web, is running Windows 10 and Visual Studio and is allowing remote access. This service is not available at San Jose City College. You would need to find it on your own.


FAQ - Form1 Is Not a Member of the Project

Q1. I get a message that Form1 is not a member of my project.
A1.

MOST LIKELY SOLUTION: Form1 may not be listed as the startup file.
1) Click on the menu item at the top named PROJECT
2) The last menu item is for 'Properties' click that one. You can also use Alt-F7 to get here
3) Find the property 'Startup form:' It has a small down-arrow that can be used to select the file.
4) If Form1 is not the startup selection, then select it.
5) See if your program will run now

Another possibility is that Form1 is not part of the project.
1) Click on the menu item at the top named VIEW
2) Click the menu item 'Solution Explorer'
3) If Form1 is not listed as part of the project, you will need to add it.
3a) Right-click the project name (example Paycheck). This is below the line with the word Solution
3b) Move the mouse to the 'Add' menu item. A sub-menu should show up to the right.
3c) Select 'Existing Item...'
3d) Click 'Form1.vb' and then click the 'Add' button

FAQ – Extra credit

Q1. Are there extra credit points available?
A1.

Extra credit points count towards the number of points earned, but are not included in the total number of points for the class. For example, if the class has a total of 100 points for all assignments, quizzes and tests and you earned 85 points + 10 points for extra credit, your grade percentage would be (85+10)/100 = 95%. If you did not have the extra credit, your percentage would be (85)/100 = 85%.

Extra credit is available in two ways:
1) An extra credit assignment is like a regular assignment, and all of the points earned are counted as extra credit. The extra points are added into the total points received for the class but Canvas shows the assignment is worth 0 points of regular credit. For example if there were two regular assignments at 10 points each and one extra credit assignment and the student received 7 points each, the total percentage would be computed as follows: (7+7+7) / (10+10+0) = 21/20 = 105%
 
2) Sometimes a regular assignment may have extra credit for doing more than the minimum required to complete the assignment. For example a 10 point assignment may have the opportunity to earn an extra 3 points for a total of 13 points out of 10. The extra credit part of the assignment MUST be turned in when the assignment is submitted. The extra credit points will not be awarded at a later date even if the assignment is resubmitted. If an assignment is worth 10 points with 3 points extra credit, Canvas initially shows the assignment as 10 points. Extra credit points are added to the total score.

FAQ - Joe's Automotive Lab Assignment

Q1. What do you charge sales tax on?
A1.

Sales tax is only charged on the value that is entered in the Parts TextBox.

 

Q2. The code provided for the project is not complete
A2. Finish coding the functions to make the program work properly. For example the Private Function FlushCharges() needs to return the total of the flush charges. Assuming the CheckBoxes inside the Flushes GroupBox are named chkRadiator and chkTransmission, add the following code to the FlushCharges() function and remove the Return 0

Dim Cost as Double = 0.0
If chkRadiator.Checked Then
   Cost += 30.0
End If
If chkTransmission.Checked Then
   Cost += 80.0
End If
Return Cost ' instead of Return 0

The MiscCharges( ) function needs to get the values from the two TextBoxes in the 'Parts and Labor' . For example, it the Parts TextBox is named txtParts then this code will get the value for parts:

Dim Cost as Double = 0.0
If txtParts.Text <> String.Empty Then
   Cost += CDbl(txtParts.Text)
End If

Something similar needs to be done for Labor inside the MiscCharges( ) function. Make sure that your return Cost instead of a Return 0

To clear a TextBox, set the Text property to String.Empty. To clear a CheckBox, set the Checked property to False

FAQ - VB Integer and Floating-point Division

Q1. What is the difference between / \ and Mod? How do you compute quotient and remainder

A1.

Floating Point Division in Visual Basic

The forward-slash / computes a floating point quotient. For example,
22 / 6 is equal to 3.66667

  ___
6 )22    is equal to 3.66667 when using floating point division


Integer Division in Visual Basic
The backslash \ computes an integer quotient. For example,
    22 \ 6 is equal to 3 (the places past the decimal are dropped)
The Mod operator computes the integer remainder. For example,
    22 Mod 6 is equal to 4

  ___
6 )22    is equal to 3, remainder 4 when using integer division

FAQ - Rock-Paper-Scissors lab project

Q1. What needs to be done to complete the Rock-Paper-Scissors lab project?
A1.

The PowerPoint presentation for the Rock-Paper-Scissors lab project does not provide a complete solution. It is going to take some extra programming on the part of the student to complete the project.

PART 1 - MAKE SURE AN EVENT HANDLER IS PRESENT FOR ALL SIX PICTURES
The Rock-Paper-Scissors program should have event handlers for each of the six pictures:
picRock1_Click (available on the PowerPoint slides)
picPaper1_Click (missing)
picScissors1_Click (missing)
picRock1_Click (missing)
picPaper2_Click (missing)
picScissors2_Click (missing)

Also code for the buttons that let the computer pick either Rock, Paper or Scissors
btnRandomPlayer1_Click (available on the PowerPoint slides)
btnRandomPlayer2_Click (missing)

These event handlers should provide the code that is to be executed when the user clicks any one of the buttons. When one of the buttons to let the computer pick is clicked, the program simulates clicking one of the pictures.

SOLUTION:
In the design mode, one at a time, double-click each of the four pictures that are missing their code and enter the appropriate code for each button. The code for each picture's click event handler will be similar. If you do a cut-and-paste, make sure that you change the code to indicate the correct player (1 or 2) and change the "Rock" to "Paper" or "Scissors" as appropriate.

PART 2 - TEST FOR ALL POSSIBLE WINNING COMBINATIONS
The "TestForWinner" also needs to be completed. See the comments on the PowerPoint slides:

' This sequence needs to be repeated six more times to test
' for Player1 = "Paper" and Player1 = "Scissors". The sequence
' of IF/ElseIf statements must be terminated with the End If

FAQ - Validating Event Handler (Rainfall Statistics)

Q1. How do you easily set a validating event handler for all of the TextBoxes?
A1.

A single Visual Basic event handler can be setup to process events from more than one control. The code below shows how to use one event handler for 12 different TextBoxes.

Private Sub rainfallTextBox_Validating(sender As TextBox, e As CancelEventArgs) Handles
  janTextBox.Validating, febTextBox.Validating, marTextBox.Validating,
  aprTextBox.Validating, mayTextBox.Validating, junTextBox.Validating,
  julTextBox.Validating, augTextBox.Validating, sepTextBox.Validating,
  octTextBox.Validating, novTextBox.Validating, decTextBox.Validating
      If IsNumeric(sender.Text)
            Dim value As Double = sender.Text

            If (value < 0)
                  MsgBox("Enter a positive value")
                  e.Cancel = True
            Else
                  e.Cancel = False
            End If
        Else

              MsgBox("The value must be a number")
              e.Cancel = True
         End If
End Sub

FAQ - OpenFileDialog control

Q1. How do you create an OpenFileDialog control?
A1.

1) The OpenFileDialog tool is located in the Dialogs group in the ToolBox.
2) Double-click the OpenFileDialog tool to place an OpenFileDialog control in the System Tray which is located at the bottom of the design view of your project.
3) You can change the name of the OpenFileDialog control by selecting it and changing its name in the Properties window.

FAQ - Windows.Forms.DialogResult - error

Q1. How do I get rid of the Windows.Forms.DialogResult.Ok error?
A1.

Microsoft likes to change things around occasionally. Some versions of Visual Basic need a fully qualified name for the dialog box result identifier, others don't. If you get an error with the squiggly red line under Windows.Forms. on
     If .ShowDialog( ) = Windows.Forms.DialogResult.Ok Then

Remove the Windows.Forms. and change the line to
     If .ShowDialog( ) = DialogResult.Ok Then

FAQ - Fit Image in PictureBox

Q1. How do I fit an image in a VB PictureBox?
A1.

Visual Basic can automatically resize an image to fit in a PictureBox control by setting the SizeMode property for the PictureBox to Zoom. After you create the PictureBox on your form, select its Properties and scroll down to SizeMode. Click the down-arrow on the right of SizeMode and select Zoom. You can now use the mouse to grab the corners of the PictureBox and watch the image automatically grow and shrink as you resize the PictureBox.

FAQ – How can the For Each loop be used to clear the Text property in a group of controls?

Q1. How can the For Each loop be used to clear the Text property in a group of controls?
A1.

The For Each loop can be used to go through a collection of controls to update a property on each control. Example: A GroupBox named grpDays is a special control that is a container that can hold other controls such as Labels, TextBoxes, Buttons, RadioButtons, CheckBoxes, etc. The GroupBox has a property named Controls that keeps track of all the controls that are part of the GroupBox.

The code below shows how to clear the Text property of each of the TextBoxes, but leave all of the other controls alone.   Dim ctrl As Control   declares ctrl to be a generic Control that can be assigned to any type of VB control. The   For Each   loop steps through each VB control that is in the GroupBox and uses an If statement to see if the selected control is referencing a TextBox. Although ctrl is referencing a TextBox, ctrl is not itself a TextBox. Since ctrl is a generic control, it could reference any type of control, and it can't be used by itself to modify properties of the control it found. However, we can use the CType(ctrl, TextBox) method to create a TextBox reference and then save it in a variable named txt of type TextBox
   Dim txt As TextBox = CType(ctrl, TextBox)

Now we have a reference named txt of type TextBox that can be used to clear the Text property of the selected TextBox.   Dim txt As TextBox = CType(ctrl, TextBox)

Dim ctrl As Control ' Control is the base class, ctrl is an object of type Control
For Each ctrl In grpDays.Controls ' step through each object in the GroupBox
  If (ctrl.GetType() Is GetType(TextBox)) Then ' is this object a TextBox
   Dim txt As TextBox = CType(ctrl, TextBox) ' -yes, txt will be one of the TextBoxes
   txt.Text = String.Empty
  End If
Next ' step through the controls to find the next TextBox
<

FAQ – How do I use the screen magnifier on Windows or macOS?

Q1. How do I use the screen magnifier on Windows or macOS
A1.

The Windows Magnifier tool can be used on any part of the screen. To activate the magnifier

click the Windows menu on the lower-left of the screen
click the gear-icon to select "Settings"
click the "Ease of Access" tool
set the Magnifier to ON

You can activate the magnifier with the "Windows" key and the "+" key
Turn off the magnifier with the "Windows" key and the "Esc" key

On a Mac and running macOS, the magnifier/Zoom tool is activated by

click the Apple icon at the upper-left of the screen
select "System Preferences"
click "Accessibility
make sure the "Zoom" shortcut is clicked in the right window pane
click Zoom in the left window pane
click the "Use keyboard shortcuts to zoom

You can activate/disable Zoom with the Option+Command+8 keys
Increase zoom with Option+Command+EqualKey (=)
Decrease zoom with Option+Command+MinusKey (-)

-End of Visual Basic FAQ