1 / 5

GROUPBOX CONTROL

Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions. GROUPBOX CONTROL The _____________________________________ is used as a container for other controls.

davidejones
Download Presentation

GROUPBOX CONTROL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual Basic ProgrammingChapter Four NotesWorking with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL • The _____________________________________ is used as a container for other controls. • This is an example of a _________________________________________ … a control that serves as a holding area for other controls, indicating that the controls are somehow related. • More often than not you’ll find radio buttons inside of the GroupBox Control. RADIO BUTTON CONTROLS • The ______________________________________________ presents a set of choices … such as the number of years in the car loan. • Radio Buttons are placed in _______________________ so that only ONE may be selected at a time. • In order to do this it is important that you draw the radio buttons directly into the GroupBox Control. If you do it right, you won’t have to write any additional code to enforce this rule – it will just work! • If you want more than one group of radio buttons just add more than one GroupBox control! • The prefix for naming radio button controls is “__________”. Example: ________________ GROUPBOX CONTROL PROPERTIES • A GroupBox Control can only have a rectangular shape. • A GroupBox Control can have a label, indicated by its Text Property Value. • When RadioButtons are added inside a GroupBox, only one can be selected at a time. • In general, you don’t have to rename your GroupBoxes since you don’t usually write code for them. FYI though: the naming prefix is “__________________” RADIO BUTTON PROPERTIES • As you’ve learned, only one radio button within a group can be on at once. • The _______________________________________ keeps track of which one is selected. • The checked property is either _____________________________. • When one button in a group becomes true, all the others automatically become false. • ______________________________ determines the 3D appearance of the control • ______________________________ – defines the visible text that displays on the control. USING THE LAYOUT TOOLBAR • The _______________________________ contains tools that allow you to adjust the alignment, spacing, and size of any group of controls on the form. • This really simplifies the task of changing the size & position of controls on your form! • To select more than one control: Press and hold down the _____________________ and then click on the other controls! • Most popular features on the layout toolbar: • Make same size • Align Lefts, Rights, Tops and Bottoms • Center Horizontally and Center Vertically • Increase or Decrease Spacing Between Controls

  2. Visual Basic ProgrammingChapter Four NotesWorking with Variables, Constants, Data Types, and Expressions COOL SHORTCUT TO PUT IN FOR THE END-USER • It is helpful to the end user if they can just hit the enter key and have the program execute it’s intended purpose. That is done by setting the _________________________. • Just select the ______________________________ property in the Form’s Property List. Just choose the button that should be the default! LOCKING CONTROLS ON A FORM • ________________________________ – This disallows the ability to move controls or modify control sizes on a form during design time – protects you from yourself! • Click on your form, then go up to Format on the menu bar, and select Lock Controls CONSTANTS AND VARIABLES • A _________________________is a number or string that programmers use in the code. • For example 150, 0.83, 8.14, “yes” or “no” • A ______________________ represents a location in computer memory that can change values as the code executes • A _______________________ represents a location in computer memory that cannot be changed during execution VARIABLES • _________________________________ are used in code statements to temporarily store values so that they may be used again in other calculations. • Variables are created by ____________________. They must have a ___________ and a ________. • The name and type are decided on by the programmer. To decide upon the type you must _____________________________________________________________________________. DATA TYPES • The __________________________ of a variable or constant determines what kind of data it can store. • Here are some VB variable types (list at least 3) _____________, ____________, ____________! VARIABLE NAMES • There are rules to naming your variables: • The name _____________________________________________________________ ! • The name ______________________________________________________________!  • The name _____________________________________________________. • The easiest way to create a variable is to __________________________________________ ___________________________________. For ex: __________________ or ________________. NAMING CONVENTIONS FOR VARIABLES • You don’t have to remember all of these at once … you’ll get the hang of them as you start creating and naming variables! Just start the variable name off with the proper prefix. Then give it a name that describes what it is storing! • Short ________ Integer ________ Long ________ • Byte ________ Decimal ________ Single ________ • Double ________ Char ________ String ________ • Boolean ________ Date ________ Object ________

  3. Visual Basic ProgrammingChapter Four NotesWorking with Variables, Constants, Data Types, and Expressions MORE ON VARIABLES • Variables created in this way may hold either numbers (________________) or characters (_______________________). • Character data is called a ________________ and must be placed in _______________________________________. Ex: name=“Christy” • Examples of code statements that assign variables: • Numeric Data -- ___________________________________ • String Data -- ___________________________________ • Value of another variable -- ___________________________________ • value of an expression -- ___________________________________ • value of an expression -- ___________________________________ • Note : the ____________________________________________ must be on the left side. UNDERSTANDING THE OPTION STRICT STATEMENT • When you use assignment statements .NET does not require you to use the same data type on both sides of the equal sign. • .NET will attempt to make it work but this can lead to a bunch of errors at run time. • For example… lets say you declare a variable as a short and then try to store a value of 50,000 in it. Shorts only go up to about 32,000. This will cause the program to come to a screeching halt. • The ________________________________ can be used to instructs Visual Basic .NET to force you to ensure that all assignment statements use the same data type on both sides of the equal sign. USING OPTION STRICT • This makes it a bit more tedious to code BUT the benefit is that .NET will let you know when you are doing it wrong and prompt you to fix it! • Being in Option Strict mode also means that ___________________________________________! • That’s good for beginning programmers. It keeps you honest!  • How do you get into Option Strict mode? In the code window on line 1, type _______________________ DECLARING A VARIABLE • Generally speaking, variables need to be _______________________. The computer needs you to tell it the _______________________________ and ______________________________________. • There are many different types of variables. • Some types are _______________, _________________, _________________, ____________. • To declare a variable you use the keyword _______________. • Example: __________________________________________ • _________________________refers to a variables ability to be accessed throughout a program. It is defined by where the variable is declared. • The scope can be limited to one procedure … for example: the variable will work within a given calculate button procedure OR it can be available throughout an entire form. Let’s give some examples: DECLARING GLOBAL VARIABLES • ________________________________________ are those that are available to all the procedures on a given form. • To declare a global variable type the Dim line in the Public Class Section of the Code Window. (Right below the REM Lines where you put your name!) • Also, put a “________________” in front of the name to indicate that it’s a global variable! • For Example: _______________________________________________ DECLARING LOCAL VARIABLES • _____________________________________ are those that only work in a single procedure. • To declare a local variable go to the specific event procedure where you want the variable to work and write the DIM statements there! • For example: in the btnCalculate_Click Event: (Give one example of a local variable declaration) • ______________________________________________________

  4. Visual Basic ProgrammingChapter Four NotesWorking with Variables, Constants, Data Types, and Expressions DECLARING CONSTANTS • Give one example of a Constant Declaration Statement using the Keyword Const: • ___________________________________________________ CONVERTING DATA TYPES • Because Option Strict is on in this chapter, you have to insure that all the data being used by the calculations has the same data type … if you don’t, you’ll get an error! • For example: In the main project the nudLoanAmount box has a Decimal Value Type. Your calculation needs to go into a Double Variable. Therefore you need to convert it. • Luckily, .NET has simple-to-use conversion statements. • For example: _______________________________________________________________ CODING A FORM LOAD EVENT PROCEDURE • Every event has a default event … for command buttons it is the Click Event. • For Forms it is the _____________________________________________. • This event executes when the form first loads into memory. • Therefore, any code you have in the Form_Load Event will trigger whenever the form loads! NUMERIC EXPRESSIONS • An ______________________ can perform a calculation, manipulate characters, call a function, or test data. • A ___________________________________ is any expression that can be evaluated as a number. • A numeric expression can include values, variables, constants, as well as certain control properties. • Expressions often contain math problems … therefore _____________________________ and ___________________________________________________________ come into play! ARITHMETIC EXPRESSIONS • VB follows the normal order of operations – which is ____________________________________________ __________________________________________. (________________________________) • Arithmetic operators in Visual Basic • _______ -- used to raise the power of an exponent • _______ -- used to multiply two numbers • _______ -- used to divide 2 #’s and return a decimal result • _______ -- used to divide 2 #’s and return an integer result • _______ -- Used to divide 2 #’s and return only the remainder • _______ -- used to sum 2 #’s • _______ -- Used to subtract 2 #’s or indicate a negative value INTRINSIC FUNCTIONS • VB programmers created a set of _______________________________ – functions that are built into .NET. • You used one of those Intrinsic Functions in your main project. It was the _______________________. • This is a financial function that will return the payment for a loan based on periodic, constant payments and a constant interest rate. • Pmt (rate, number of periods, pv, fv, due) • This is what it looked like in your code: ______________________________________________. • There is a list of additional intrinsic functions on page 4.59 in your book! USING THE FORMAT$ FUNCTION • The Format$ Function is an Intrinsic function that allows you to apply a “better look” to your output. • For instance, what if you want to round an answer to a certain number of decimal places OR you want the answer to display as a $$$ value. Use the format$ function! • ___________________________________ -- function that allows the programmer to determine how the output will appear on the screen. • Ex: ________________________________________________________________________ • Some popular formats are ________________________, _________________________, ____________________________, ________________________ and _________________.

  5. Visual Basic ProgrammingChapter Four NotesWorking with Variables, Constants, Data Types, and Expressions Use the note space below for the following Coding 101 topics: • Valid and invalid variable names • Arithmetic operators • Order of operation _________________________________________________________________

More Related