Procedure Name | Type | Description |
(Declarations) | Declarations | Declarations and private variables for the modDataConversion module. |
AtLeast | Procedure | Get the greater of two values. |
AtMost | Procedure | Get the lesser of two values. |
VarToRoundLong | Procedure | Converts the passed variant to a long integer and rounds it using arithmetic rounding. Nulls are returned as 0. |
DelimitSendKeys | Procedure | Fixes sendkeys statements by delimiting magic characters. This procedure converts a string to a SendKeys compatible format. Several characters have special meaning to the Sendkeys actions. This procedure delimits any occurrences of those special characters by wrapping them in braces {}. |
NullIfZero | Procedure | Get Null if the passed value is zero, otherwise returns the passed value. |
NullIfZLS | Procedure | Get Null if the passed value is a zero-length string (""), otherwise returns the passed value. |
OverpunchedStringToNumber | Procedure | Converts a "zoned overpunch" number to a regular number. Many mainframe and minicomputer systems written in COBOL and other
languages use a numeric format known as zoned overpunch. The numbers consist of normal ASCII characters, except that the last character indicates
the sign of the number. For example, the following "number": 12345 F is actually: 123456. While 12345 O is actually: -123456. Decimal places are implied. A positive zero is "{" and a number ending in a negative zero is "}". |
VarToCurrency | Procedure | Converts the passed variant to a currency value, 0 if the passed value is Null. |
VarToDouble | Procedure | Converts the passed variant to a double, returning 0 if the passed value is Null. |
VarToInteger | Procedure | Converts the passed variant to an integer, returning 0 if the passed value is Null. |
VarToLong | Procedure | Converts the passed variant to a long integer, returning 0 if the passed value is Null. |
VarToString | Procedure | Converts the supplied variant to a string. Nulls are returned as a zero-length string (""). |
ZeroIfNull | Procedure | Get zero if Null is passed, otherwise returns the passed value. For Access/VBA, use the built in NZ command instead. |
ZLSIfNull | Procedure | Get a zero-length string ("") if Null is passed, otherwise returns the passed value. |
' Example of modDataConversion ' ' To use this example, create a new module and paste this code into it. ' Then run the procedure by putting the cursor in the procedure and pressing: ' F5 to run it, or ' F8 to step through it line-by-line (see the Debug menu for more options) Private Sub Example_modDataConversion() ' Comments: Examples of using the modDataConversion module to convert data with VBA and VB6. ' See the results in the Immediate Window. Const cstrTmp As String = "%f^cb" Debug.Print "AtLeast(12, 2) returns " & AtLeast(12, 2) Debug.Print "AtMost(12, 2) returns " & AtMost(12, 2) Debug.Print "DelimitSendkeys(): input value of " & cstrTmp & " returns " & DelimitSendKeys(cstrTmp) Debug.Print "NullIfZLS(): input value of 's' returns: " & NullIfZLS("s") Debug.Print "ZLSIfNull(): input value of Null returns: " & ZLSIfNull(Null) Debug.Print "ZeroIfNull(): input value of Null returns: " & ZeroIfNull(Null) Debug.Print "NullIfZero(): input value of 2 returns: " & NullIfZero(2) Debug.Print "OverpunchedStringToNumber(): input value of 1234 returns: " & OverpunchedStringToNumber(1234, 2) Debug.Print "VarToCurrency(): input value of 1234.56 returns: " & VarToCurrency(12345.56) Debug.Print "VarToDouble(): input value of Null returns: " & VarToDouble(Null) Debug.Print "VarToInteger(): input value of Null returns: " & VarToInteger(Null) Debug.Print "VarToLong(): input value of Null returns: " & VarToLong(Null) Debug.Print "VarToRoundLong(): input value of 45.67889 returns: " & VarToRoundLong(45.67889) Debug.Print "VarToString(): input value of Null returns: " & VarToString(Null) End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP