More on String Functions - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

More on String Functions

Description:

The numbering system is called American Standard Code for Information Interchange (ASCII) ... VAL('Antelope') is equal to 0. Sample Program ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 11
Provided by: IMT
Category:

less

Transcript and Presenter's Notes

Title: More on String Functions


1
More on String Functions
2
ASCII Codes
  • The computer stores individual characters as
    numbers.
  • The numbering system is called American Standard
    Code for Information Interchange (ASCII).
  • Numbers 0 255 are used.

3
CHR( )
  • CHR(number) gives the character represented by
    the ASCII code number in the parentheses.
  • Examples
  • PRINT CHR(34) gives you output of
  • PRINT CHR(65) will print A
  • PRINT CHR(33) prints ! 

4
ASC( )
  • ASC(Some) gives the ASCII code of the first
    letter of Some.
  • Examples
  • PRINT ASC(M) gives you output of 77.
  • PRINT ASC(Mom) is also 77.
  • PRINT ASC(!) prints 33. 

5
 STR( )
  • STR( ) converts numbers to strings.
  • Examples
  • STR(36.8) is the string 36.8.
  • STR(Year) is the string 2000.

Notice the single blank space left before a
number!
6
Sample Program
  • STR( ) changes a number into a string so it can
    be manipulated with string functions.

Year 2001 Year STR(Year) PRINT Seniors are
the class of PRINT RIGHT(Year,2)
Seniors are the class of 01
7
VAL( )
  • VAL( ) converts a string to a number.
  • Examples
  • PRINT VAL(321) 2 prints 642.
  • VAL(23KIDOO) is the number 23.
  • VAL(Antelope) is equal to 0.

8
Sample Program
  • VAL( ) changes the numeric portion of a string
    into a number so it can be used in an arithmetic
    expression.

Team Phoenix...Suns......19.7 Wins
VAL(MID(Team, 21,2)) Losses
VAL(RIGHT(TEAM,2)) PRINT Suns won
Wins-Losses PRINT more games than they lost. 
9
Notes
  • ASC( ) VAL ( ) can only have strings within the
    parentheses.
  • ASC( ) VAL( ) represent numbers.
  • CHR( ) STR( ) can only have numbers within
    the parentheses.
  • CHR( ) STR( ) represent strings.

10
That was a lot of information
Write a Comment
User Comments (0)
About PowerShow.com