Access VBA Macro Programming

(Joao Candeias) #1

Chapter 5 Strings, Functions, and Message Boxes


Chapter 5 Strings, Functions, and Message Boxes


T


his chapter covers how to handle strings of text, how to use the built-in functions of
VBA, and how to design professional message boxes.

Strings


If you already use Access frequently, you will know that a string is not something that you
cut off from a ball of string and use around the house. It is instead a stream of consecutive
characters. They are not limited to the alphabet but can be any character within the character
set (0 to 255). This covers all alphanumeric and control characters. These can be different
according to what language code page you are using, but there are still only 256 characters.
A string is useful for displaying a message to the user or providing a caption. A string could
be "Richard", or it could be "1234".
VBA provides a number of functions for concatenating (joining) strings together, removing
sections, searching, and changing case (to upper- or lowercase). For example, if you have a
string "Your answer" and another " is wrong", you can join these together into one string:
"Your answer is wrong". You can also use a function to change the entire string to uppercase
characters so it reads "YOUR ANSWER IS WRONG", or you can search for a particular
word or set of characters within the string.


45

Free download pdf