DEBUGGING:

CATEGORIES OF PROBLEMS: A. VISUAL BASIC WON’T RUN B. VISUAL BASIC RUNS, BUT THE PROGRAM DOESN’T DO WHAT I WANT IT TO. A. VISUAL BASIC WON’T RUN: 1. The VISUAL BASIC editor says, “Expecting Expression” When typing in commands, you either hit a carriage return before you were supposed to, or you forgot some part of the command, such as a “TO” on a FOR-TO-STEP-NEXT command, or perhaps a parentheses ( ), etc. 2. The VISUAL BASIC editor says, “cannot find object” The biggest source of errors is you don’t use the right variable names. Make sure that the name property on the object is spelled correctly. Then every time you reference that object, make sure you spell it exactly the same way. For example, if Visual Basic does not recognize a SHOW or HIDE command, then check the property name on the form object. It must be equal to the form name on the HIDE and SHOW commands. You can check your form names from either the project window or the properties window 3. VISUAL BASIC doesn’t know which form to load first Go to the menu bar and select “Option” Select “Project” Type in “FrmTitle” at the Start-Up-Form Line B. VISUAL BASIC RUNS, BUT THE PROGRAM DOESN’T DO WHAT I WANT IT TO. 1. If your menu doesn’t look right, go back to the menu design window and make sure you specified the right menu captions, menu names, and the right “arrows” 2. If your Window is not maximized at runtime, Change the property Widowstate to Maximized on the Form object. 3. If your fonts are too small, change the font-size 4. “My list box on the FRMPAY.FRM doesn’t have a scroll bar” That’s okay; you just made your list box big enough to display all the terms (1 2 3 4 5 6) 5. “My Rocket Icon won’t get big” Change the stretch property on the Image object. The most common errors occur when students don’t understand how variables within a form or across forms relate to each other. When we first create an object on a form, we give the object a name in the name property. Everytime we refer to this object throughout a system, we must use the correct name. FOR EXAMPLE, ON THE FRMTITLE, THE THE FOLLOWING OBJECT WAS CREATED: FORM OBJECT TYPE NAME PROPERTY FrmTitle Form FrmTitle LOOK AT ALL THE OTHER PLACES IN THE SYSTEM WE REFERENCE THIS OBJECT: FORM OBJECTTYPE NAME PROPERTY CODING FrmTitle MENU MnuFileOpenNotes FrmTitle.Hide FrmTitle MENU MnuFileOpenPayment FrmTitle.Hide FrmTitle MENU MnuFileOpenQuote FrmTitle.Hide FrmCust Command CmdExit FrmTitle.Show FrmPay Command CmdExit FrmTitle.Show FrmQuote Command CmdExit FrmTitle.Show

ON THE FRMCUST LOOK AT ALL THE CROSS-REFERENCES:

THE FOLLOWING OBJECT WAS CREATED: FORM OBJECT TYPE NAME PROPERTY FrmCust Form FrmCust FORM OBJECTTYPE NAME PROPERTY CODING FrmCust Command CmdOK FrmCust.Hide FrmTitle MENU MnuFileOpenNotes FrmCust.Show FrmCust Command CmdExit FrmCust.Hide FrmNotes MENU MnuFileExit FrmCust.Show For the following objects, can you identify all the places the object name is used? FORM OBJECT TYPE NAME PROPERTY FrmCust Textbox TxtName Textname is referrenced in 4 other places in our system: 1. FrmCust Command CmdOK Line1 = TxtName.Text 2. FrmCust Command CmdOK IF TxtName.Text = “” OR TxtAddr.Text =“” OR TxtCity.Text = “” OR TxtState.Text = “” OR TxtZip.Text = “” THEN Msgbox “Please Complete The Customer Information Form”ELSE FRMCUST.HIDE ENDIF 3. FrmNotes MENU MnuFileExit Frmcust.TxtName.Text = “” 4. FrmNotes MENU MnuFileExit FrmCust.TxtName.SetFocus FORM OBJECT TYPE NAME PROPERTY FrmCust Textbox TxtAddr 1. FrmCust Command CmdOK Line2 = TxtAddr.Text 2.FrmCust Command CmdOK IF TxtName.Text = “” OR TxtAddr. Text =“” OR TxtCity.Text = “” OR TxtState.Text = “” OR TxtZip.Text = “” THEN Msgbox “Please Complete The Customer Information Form”ELSE FRMCUST.HIDE ENDIF 3. FrmNotes MENU MnuFileExit Frmcust.TxtAddr.Text = “” See if you can find all the other cross references for the following variables: FORM OBJECT NAME PROPERTY FrmCust Textbox TxtCity 1. 2. 3. FORM OBJECT NAME PROPERTY FrmCust Textbox TxtState 1. 2. 3. FORM OBJECT NAME PROPERTY FrmCust Textbox TxtZip 1. 2. 3. ON THE FRMNOTES, FIND ALL THE CROSS-REFERENCES FOR OBJECTS CREATED ON THIS FORM: FORM OBJECT NAME PROPERTY FrmNotes Form FrmNotes 1. FORM OBJECT NAME PROPERTY FrmNotes Textbox TxtCustomer 1. FORM OBJECT NAME PROPERTY FrmNotes Textbox TxtNote 1. FORM OBJECT NAME PROPERTY FrmNotes Textbox TxtDate FrmNotes 1. 2. FORM OBJECT NAME PROPERTY FrmNotes Textbox TxtSalutation 1. 2. FORM OBJECT NAME PROPERTY FrmNotes Textbox TxtNote 1. 2. SOME MORE DEBUGGING “I have a little icon stuck in the top left hand side of my form” Select the Form object, change the Picture Property to none “I have phantom objects in my properties box which are not on my form” Hit the tab key...until the cursor lands on something not on your form. Look at the properties Window. Look at the TOP and LEFT properties. Is your object hiding under another object? Is your object off the screen altogether? “I have phantom coding I can’t get rid of” Go to the coding box. Select “GENERAL”, pull down the “DECLARATIONS” bar. All phantom code will be displayed here. You can delete it from here. “I have index errors and array errors” You tried to name two different objects the same name. VISUAL BASIC asked you if you wanted to create an array and you said yes. To back out of this error: Find the object you don’t want Change the name property Change the Index Property to Blank Delete the Object