Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ppt lesson 07


Published on

  • Be the first to comment

Ppt lesson 07

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