Chapter 3: Using Variables and Constants

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/94

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

95 Terms

1
New cards

Controls, Variable

In VB.NET________ and _________ temporarily store data.

2
New cards

data type, name, scope, lifetime

A variable is specified by ________, _________, __________, and __________.

3
New cards

Data type

Specifies type of data a variable can store

4
New cards

Data type

Provides a class template for creating variables

5
New cards

Unicode

Universal coding scheme for characters

6
New cards

Unicode

Assigns unique numeric value to each character in the written languages of the world

7
New cards

Boolean

Basic data types:

It stores a logical value(true, false) and requires 2 bytes

8
New cards

Char

Basic data types:

Stores a Unicode character and requires 2 bytes

9
New cards

Date

Basic data types:

Stores data and time information and requires 8 bytes

10
New cards

Decimal

Basic data types:

Stores a number with a decimal place and requires 16 bytes

11
New cards

Double

Basic data types:

Stores a number with a decimal place and requires 8 bytes

12
New cards

Integer

Basic data types:

Stores a number and requires 4 bytes

13
New cards

Long

Basic data types:

Stores a number and requires 8 bytes

14
New cards

Object

Basic data types:

Stores a data of any type and requires 4 bytes

15
New cards

Short

Basic data types:

Stores a number and requires 2 bytes

16
New cards

Single

Basic data types:

Stores a number with decimal place and requires 4 bytes

17
New cards

String

Basic data types:

Stores text of 0 to approximately 2 billion characters

18
New cards

Variable

It is used to store information and are referred to by name

19
New cards

Identifier

Another term for variable name

20
New cards

Hungarian Notation, three-character prefix

Naming Variables: Use _____________, with a ____________________ representing the variable’s data type

21
New cards

Descriptive

Naming Variables: Name should be __________

22
New cards

Camel case

Naming Variables: Use _______________: e.g., dblSalesAmount

23
New cards

letter, underscore

Naming Variables: The name must begin with a _________ or an ____________

24
New cards

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.

25
New cards

32

Naming Variables: Although the name can contain thousands of characters, _____ characters is the recommended maximum number of characters to use.

26
New cards

reserved

Naming Variables: The name cannot be a __________ word, such as Sub or Double

27
New cards

Declaration Statement

Used to declare (create) a variable and reserve space in memory for it

28
New cards

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

29
New cards

Assignment Statement

Assigns value to variable at run time

30
New cards

Assignment Statement

Expression may include literal constants, object properties, variables, keywords, arithmetic operators

31
New cards

Literal Constant

Data item whose value does not change

32
New cards

Literal type character

Forces literal constant to change data type

33
New cards

TryParse method

Converts string to number

34
New cards

Val

TryParse is preferred over ______

35
New cards

Double

Val only returns a type ______ value

36
New cards

TryParse

Allows programmer to specify data type

37
New cards

dataType.TryParse(string, numericVariableName)

Syntax of TryParse

38
New cards

Convert Class

Can be used to convert a number from one type to another

39
New cards

TryParse

________ is recommended for converting strings to numeric data types

40
New cards

TryParse Method

Method that will not produce an error if conversion fails

41
New cards

Convert.method(value)

Syntax of Convert class

42
New cards

Scope

Indicates where variable can be used

43
New cards

Lifetime

It is how long a variable remains in memory

44
New cards

Scope and Lifetime

these are determined by where variable is declared

45
New cards

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

46
New cards

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

47
New cards

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

48
New cards

Static variable

Procedure-level variable with extended lifetime

49
New cards

Static variable

Remains in memory between procedure calls

50
New cards

Static variable

Retains its value even when the procedure ends

51
New cards

Static keyword

Used to declare static variable

52
New cards

Static variable

___________ act like class-level variables but have narrower scope. Can only be used within procedure where declared

53
New cards

Named constant

Memory location inside computer whose contents cannot be changed at run time

54
New cards

Const statement

This creates a named constant

55
New cards

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

56
New cards

Const constantName As dataType = expression

Syntax of named constant

57
New cards

Option Explicit On

This prevents you from using undeclared variables

58
New cards

Implicit type conversion

Converts right-side value to the data type of left side

59
New cards

Promotion

Data converted to greater precision number

60
New cards

Demotion

Data us truncated and data loss can occur when it happens

61
New cards

Option Infer Off

Ensures that every variable is declared with a data type

62
New cards

Option Strict On

Disallows implicit conversions

Type conversion rules are applied when this option is on

63
New cards

{Dim | Private | Static}

Declare a variable using the following keywords:

64
New cards

Option Explicit On

Enforces full variable declaration

65
New cards

Option Infer Off

Enforces that variables are declared with data types

66
New cards

Option Strict On

Suppresses implicit type conversions

67
New cards

Concatenate

Connect strings together

68
New cards

Concatenation operator

Ampersand (&) is used as a?

69
New cards

strings

Numeric values used with the & operator are converted to ________

70
New cards

InputBox function

Displays dialog box and retrieves user input

71
New cards

prompt

Message to display inside dialog box

72
New cards

title

Text to display in the dialog box’s title bar

73
New cards

defaultResponse

Text to be displayed in the input field

74
New cards

Returned

________ value most often assigned to String variable

75
New cards

InputBox(prompt[, title][, defaultResponse])

Syntax of the InputBox function

76
New cards

ControlChars.NewLine constant

Advances the insertion point to the next line in a control

77
New cards

ControlChars.NewLine constant

This is also used to advance insertion point in file or on printer

78
New cards

String concatenation

ControlChars.NewLine can be used in _________ _____________

79
New cards

Line continuation character (_)

Used to break up long lines of code into two or more lines

80
New cards

Default Button

Button that is activated by pressing Enter key

Button is not required to have the focus

Only one per form

81
New cards

Default button

this button should be button used most often by the user

82
New cards

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

83
New cards

Formatting

Specifying decimal places and special characters to display

84
New cards

ToString Method

Formatting numbers to strings method

85
New cards

variablename.ToString(formatString)

Syntax of ToString method

86
New cards

format String

it has a form of Axx specifying a format and precision specifier

87
New cards

AcceptButton

Set default button in form’s ___________ property

88
New cards

TextChanged event

Occurs when the Text property value of a control changes

89
New cards

text

This event can occur when:

The user enters data into the control

Code assigns data to the control’s ___ property

90
New cards

Handles

Appears in an event procedure’s header

91
New cards

Handles clause

Indicates object and event associated with procedure

92
New cards

Handles

Can associate an event procedure with more than one object and/or event

93
New cards

commas

In Handles section of procedure header, list each object and event, separated by _________

94
New cards
95
New cards