Download presentation
Presentation is loading. Please wait.
Published byErika Ball Modified over 8 years ago
1
CSC 162 Visual Basic I Programming
2
String Functions LTrim( string ) –Removes leading spaces from the left side of string RTrim( string ) –Removes trailing spaces from the right side of string Trim( string ) –Removes leading spaces from the left side and trailing spaces from the right side of string
3
String Functions StrReverse( string ) –Reverses all the characters in string UCase( string ) –Converts all the characters in string to uppercase LCase( string ) –Converts all the characters in string to lowercase Replace( string, replacee, replacor, position ) –Replaces all occurrences of substring replacee with replacor beginning at position in string –position is optional (default value = 1).
4
String Functions String( quantity, character ) –Creates a string of quantity number of characters –character can either be a literal or a numeric code (65 = "A", 97 = "a", 42 = "*", etc.) Space( quantity ) –Creates a string of quantity number of spaces ( " " )
5
String Functions Asc( character ) –Returns the ASCII numeric code of character Chr( code ) –Returns the ASCII character whose number is code Val( string ) –Returns the numeric value of string –Caution: Val will convert expressions that begin with a number (Examples: 30something, 4ever, etc.) Str( number ) –Returns the string equivalent of number
6
String Functions IsNumeric( string ) –Returns whether string can represent a number (True / False) Hex( number ) or Hex( string ) –Formats number or string in hexadecimal notation Oct( number ) or Oct( string ) –Formats number or string in octal notation
7
Lab Assignment Create a data validation loop in which the user is continuously prompted ( InputBox ) for numeric input. 1.If the user enters a non-numeric value, the program should display an error message ( MsgBox ) and re-prompt for input. 2.If the user enters a numeric value, the program should display a congratulatory message ( MsgBox ). 3.If the user presses the Cancel button, the program should do nothing.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.