VBA Cos Function
Microsoft Office VBA:
Visual Basic Functions Tutorial
Welcome to our VBA Functions for Microsoft Access home page. This section of our website contains all of the predefined functions available to you in a Microsoft Access database.
Web site navigation for our Visual Basic function discussion is listed to the right. Of course, Access gives you the ability to create any VB function you can think of. But it is good to know what VB functions already exist so you don't re-invent the wheel.
Blue Claw Database Design is your premier source of Microsoft Access Programming and database support.
With our new partnership with IT Impact we have extensive programming support in SQL/Server database, MS Access software, Power BI applications, .Net web development, PHP, Excel & Outlook customization.
We will give the syntax, discussion and examples of each of the functions listed to the left as we go down the page. We didn't create these Access database functions so most of the syntax and usage information is taken from the Microsoft Access Visual Basic help system. We have added our own notes and discussion to help clarify the functions where we can. Let's get started!
The Visual Basic Abs function simply removes the sign from a number returning a positive value. This is useful for calculating the absolute difference between values and adding them differences up. You would first use the Abs function before adding the values.
This example uses the Abs
function to compute the absolute value of a number.
The Microsoft Access Array function establishes an array (list) of values. To create a constant array you define the array name as a variant. See below;
Dim myArray as Variant
myArray = Array(5,10,15,21)
You can then refer to an array element by its integer position starting at 1:
The Msgbox above will display the number 10
The VBA Asc function returns the ASCII character code for the 1st letter in the Asc argument:
TheNumber = Asc("A")
' Returns 65.
Here is a complete ASCII character chart. Visual Basic Atn Function
The arctangent is used to calculate the angles of a right triangle. It works opposite of the tangent function. While tangent will find the ratio of the two sides of a right triangle when given an angle, arctangent can find the angle given the ratio. Go here to see more information on arctangent.
This example uses the Atn function to calculate the value of pi.
CallByName() function is used to manipulate objects by either executing a method
or setting the value of a property.
calltype - Required; Constant. A constant of type vbCallType representing
the type of procedure being called.
Choose returns a value from the list of choices based on the value of index. If index is 1, Choose returns the first choice in the list; if index is 2, it returns the second choice, and so on.
The Visual Basic Chr function returns a string containing the character associated with the specified character code.
More examples of the Chr function: CreateQueryDef in VBA
The Visual Basic Command function returns the argument part of the command line used to invoke MS Visual Basic or an program developed with Visual Basic. The Visual Basic Command function is not available in Microsoft Office applications.
When Visual Basic is launched from the command line, any portion of the command
line that follows ' /cmd ' is forwarded to the program as an argument. In
the example below, cmdlineargs is the argument information returned
by the Command function.
Copyright 2000-2017 Blue Claw Database Design
Access Visual Basic/VB/VBA/VBScript/VB6 2013 2010 2007 All Windows Versions