1/94
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Controls, Variable
In VB.NET________ and _________ temporarily store data.
data type, name, scope, lifetime
A variable is specified by ________, _________, __________, and __________.
Data type
Specifies type of data a variable can store
Data type
Provides a class template for creating variables
Unicode
Universal coding scheme for characters
Unicode
Assigns unique numeric value to each character in the written languages of the world
Boolean
Basic data types:
It stores a logical value(true, false) and requires 2 bytes
Char
Basic data types:
Stores a Unicode character and requires 2 bytes
Date
Basic data types:
Stores data and time information and requires 8 bytes
Decimal
Basic data types:
Stores a number with a decimal place and requires 16 bytes
Double
Basic data types:
Stores a number with a decimal place and requires 8 bytes
Integer
Basic data types:
Stores a number and requires 4 bytes
Long
Basic data types:
Stores a number and requires 8 bytes
Object
Basic data types:
Stores a data of any type and requires 4 bytes
Short
Basic data types:
Stores a number and requires 2 bytes
Single
Basic data types:
Stores a number with decimal place and requires 4 bytes
String
Basic data types:
Stores text of 0 to approximately 2 billion characters
Variable
It is used to store information and are referred to by name
Identifier
Another term for variable name
Hungarian Notation, three-character prefix
Naming Variables: Use _____________, with a ____________________ representing the variable’s data type
Descriptive
Naming Variables: Name should be __________
Camel case
Naming Variables: Use _______________: e.g., dblSalesAmount
letter, underscore
Naming Variables: The name must begin with a _________ or an ____________
punctuation characters, special characters, spaces
Naming Variables: The name can contain only letters, numbers, and the underscore character. No _________________, __________________, or _________ are allowed in the name.
32
Naming Variables: Although the name can contain thousands of characters, _____ characters is the recommended maximum number of characters to use.
reserved
Naming Variables: The name cannot be a __________ word, such as Sub or Double
Declaration Statement
Used to declare (create) a variable and reserve space in memory for it
Default Value
If no initial value is given to variable when declaring it, computer stores the _______________.
Numeric variables are set to 0
Boolean variables are set to False
Object and String variables are set to Nothing
Date variables are set to 1/1/0001 12:00:00AM
Assignment Statement
Assigns value to variable at run time
Assignment Statement
Expression may include literal constants, object properties, variables, keywords, arithmetic operators
Literal Constant
Data item whose value does not change
Literal type character
Forces literal constant to change data type
TryParse method
Converts string to number
Val
TryParse is preferred over ______
Double
Val only returns a type ______ value
TryParse
Allows programmer to specify data type
dataType.TryParse(string, numericVariableName)
Syntax of TryParse
Convert Class
Can be used to convert a number from one type to another
TryParse
________ is recommended for converting strings to numeric data types
TryParse Method
Method that will not produce an error if conversion fails
Convert.method(value)
Syntax of Convert class
Scope
Indicates where variable can be used
Lifetime
It is how long a variable remains in memory
Scope and Lifetime
these are determined by where variable is declared
Class: Variable can be used by all procedures in a form
Procedure: Variable can be used within procedure
Block: Variable can be used within specific code block
Three types of scope
Can be used only by that procedure
Declared at beginning of procedure
Removed from memory when procedure ends
Declared using Dim keyword
Four things to remember for variables with procedure scope
Can be used by all procedures in a form
Declared in form’s Declarations section
Remain in memory until application ends
Declared using Private keyword
Four things to remember for variables with class scope
Static variable
Procedure-level variable with extended lifetime
Static variable
Remains in memory between procedure calls
Static variable
Retains its value even when the procedure ends
Static keyword
Used to declare static variable
Static variable
___________ act like class-level variables but have narrower scope. Can only be used within procedure where declared
Named constant
Memory location inside computer whose contents cannot be changed at run time
Const statement
This creates a named constant
Const statement
Stores value of expression in named constant
expression: Can be literal constant, another named constant, or an arithmetic operator
Cannot contain a variable or method
Const constantName As dataType = expression
Syntax of named constant
Option Explicit On
This prevents you from using undeclared variables
Implicit type conversion
Converts right-side value to the data type of left side
Promotion
Data converted to greater precision number
Demotion
Data us truncated and data loss can occur when it happens
Option Infer Off
Ensures that every variable is declared with a data type
Option Strict On
Disallows implicit conversions
Type conversion rules are applied when this option is on
{Dim | Private | Static}
Declare a variable using the following keywords:
Option Explicit On
Enforces full variable declaration
Option Infer Off
Enforces that variables are declared with data types
Option Strict On
Suppresses implicit type conversions
Concatenate
Connect strings together
Concatenation operator
Ampersand (&) is used as a?
strings
Numeric values used with the & operator are converted to ________
InputBox function
Displays dialog box and retrieves user input
prompt
Message to display inside dialog box
title
Text to display in the dialog box’s title bar
defaultResponse
Text to be displayed in the input field
Returned
________ value most often assigned to String variable
InputBox(prompt[, title][, defaultResponse])
Syntax of the InputBox function
ControlChars.NewLine constant
Advances the insertion point to the next line in a control
ControlChars.NewLine constant
This is also used to advance insertion point in file or on printer
String concatenation
ControlChars.NewLine can be used in _________ _____________
Line continuation character (_)
Used to break up long lines of code into two or more lines
Default Button
Button that is activated by pressing Enter key
Button is not required to have the focus
Only one per form
Default button
this button should be button used most often by the user
destructive, irreversible
If the default button’s task is _________ and _________, such as deleting data, it should not be the most often button clicked by the user
Formatting
Specifying decimal places and special characters to display
ToString Method
Formatting numbers to strings method
variablename.ToString(formatString)
Syntax of ToString method
format String
it has a form of Axx specifying a format and precision specifier
AcceptButton
Set default button in form’s ___________ property
TextChanged event
Occurs when the Text property value of a control changes
text
This event can occur when:
The user enters data into the control
Code assigns data to the control’s ___ property
Handles
Appears in an event procedure’s header
Handles clause
Indicates object and event associated with procedure
Handles
Can associate an event procedure with more than one object and/or event
commas
In Handles section of procedure header, list each object and event, separated by _________