Microsoft Visual Basic 2005 BASICS yo Microsoft Visual Basic 2005 BASICS Lesson 7 Strings and Decimal Types
Objectives Declare string variables. Assign text to string variables. yo Objectives Declare string variables. Assign text to string variables. Concatenate strings. Use decimal data types. Use the Format function. Microsoft Visual Basic 2005 BASICS
Objectives (cont.) Use the Enabled property. yo Objectives (cont.) Use the Enabled property. Use the SelectionStart and SelectionLength properties. Microsoft Visual Basic 2005 BASICS
Declaring String Variables yo Declaring String Variables Text is often called alphanumeric data. Can include letters or numbers Data types that hold text are usually referred to as strings. When you declare a string, the resulting variable can hold a string of any practical length. Microsoft Visual Basic 2005 BASICS
Assigning Text to String Variables yo Assigning Text to String Variables Place the text in quotation marks. Hard-coded text is called a string literal. Like a numeric variable, a string variable can only hold one string. Each time you assign a string to a string variable, the existing data is replaced. Microsoft Visual Basic 2005 BASICS
Assigning Text to String Variables (cont.) Microsoft Visual Basic 2005 BASICS
Assigning Text to String Variables (cont.) Microsoft Visual Basic 2005 BASICS
Concatenation Concatenation Ampersand (&) yo Concatenation Concatenation Appends one string to the end of another Ampersand (&) You can concatenate more than two strings in one expression. You can also use concatenation when creating the text for a label. Microsoft Visual Basic 2005 BASICS
Concatenation (cont.) Microsoft Visual Basic 2005 BASICS
Concatenation (cont.) Microsoft Visual Basic 2005 BASICS
Concatenation (cont.) Microsoft Visual Basic 2005 BASICS
Concatenation (cont.) Microsoft Visual Basic 2005 BASICS
Using Decimal Types Single data type Double data type yo Using Decimal Types Single data type Used for decimal values that will not exceed 38 digits Double data type Used for decimal values with more than 38 digits Decimal data type Used to work with dollars and cents Microsoft Visual Basic 2005 BASICS
Using the Format Function yo Using the Format Function The Format function Allows you to apply custom formatting to a number before displaying the value The Format function can be used to format decimal values, phone numbers, and more. Microsoft Visual Basic 2005 BASICS
Using the Format Function (cont.) Microsoft Visual Basic 2005 BASICS
Using the Format Function (cont.) Microsoft Visual Basic 2005 BASICS
Using the Format Function (cont.) Microsoft Visual Basic 2005 BASICS
Using the Enabled Property yo Using the Enabled Property Enabled property Makes a control take on a grayed appearance that makes it inactive but still visible Objects that are inactive can be seen by the user, but will not respond to user actions. Microsoft Visual Basic 2005 BASICS
Using the Enabled Property (cont.) To disable an object, set the Enabled property to False. Microsoft Visual Basic 2005 BASICS
Using the SelectionStart and SelectionLength Properties yo Using the SelectionStart and SelectionLength Properties SelectionStart property Specifies the location where the insertion point will be inserted when the text box gets the focus SelectionLength property Specifies how many characters should be selected to the right of the cursor Microsoft Visual Basic 2005 BASICS
Using the SelectionStart and SelectionLength Properties (cont.) Microsoft Visual Basic 2005 BASICS
Summary Strings hold text or alphanumeric data. yo Summary Strings hold text or alphanumeric data. Visual Basic has a data type for strings. Text assigned to a string variable must be placed in quotation marks. You can use the assignment operator to assign text from a text box to a string variable or from a string variable to another string variable. Microsoft Visual Basic 2005 BASICS
yo Summary (cont.) Concatenation is the process of appending one string to the end of another. The ampersand (&) is the symbol used for concatenation. The Single, Double, and Decimal data types hold decimal data. The Decimal data type is specially designed for handling dollars and cents. Microsoft Visual Basic 2005 BASICS
yo Summary (cont.) The Format function uses a string of symbols to format decimal values, phone numbers, and more. The Enabled property is used to make a control inactive or active. The SelectionStart and SelectionLength properties and the Len function can be used together to highlight the text in a text box. Microsoft Visual Basic 2005 BASICS