Number Functions
| ABS | Returns the absolute value of a number (Variant). |
| ATN | Returns the arctangent of a number in radians (Double). |
| COS | Returns the cosine of an angle in radians (Double). |
| EXP | Returns the base of natural logarithm raised to a power (Double). |
| FIX | Returns the integer portion of a number (Integer). |
| FORMAT | Returns the text string of a number or date in a particular format (String). |
| HEX | Returns the number converted to hexadecimal (String). |
| INT | Returns the number rounded down to the nearest integer (Integer). |
| ISNUMERIC | Returns the value indicating if an expression contains a number (Boolean). |
| LOG | Returns the natural logarithm of a number (Double). |
| MOD | Returns the remainder after division (Integer). |
| OCT | Returns the number converted to octal (Variant). |
| RANDOMIZE | Initialises the random number generator. |
| RND | Returns a random number between 0 and 1 (Single). |
| ROUND | Returns a number rounded to a given number of decimal places (Double). |
| SGN | Returns the sign of a number (Integer). |
| SIN | Returns the sine of an angle in radians (Double). |
| SQR | Returns the square root of a number (Double). |
| TAN | Returns the tangent of an angle (Double). |
| ABS Returns the absolute value of a number (Variant). |
| ATN Returns the arctangent of a number in radians (Double). |
| COS Returns the cosine of an angle in radians (Double). |
| EXP Returns the base of natural logarithm raised to a power (Double). |
| FIX Returns the integer portion of a number (Integer). |
| FORMAT Returns the text string of a number or date in a particular format (String). |
| HEX Returns the number converted to hexadecimal (String). |
| INT Returns the number rounded down to the nearest integer (Integer). |
| ISNUMERIC Returns the value indicating if an expression contains a number (Boolean). |
| LOG Returns the natural logarithm of a number (Double). |
| MOD Returns the remainder after division (Integer). |
| OCT Returns the number converted to octal (Variant). |
| RANDOMIZE Initialises the random number generator. |
| RND Returns a random number between 0 and 1 (Single). |
| ROUND Returns a number rounded to a given number of decimal places (Double). |
| SGN Returns the sign of a number (Integer). |
| SIN Returns the sine of an angle in radians (Double). |
| SQR Returns the square root of a number (Double). |
| TAN Returns the tangent of an angle (Double). |
Dim number As Variant
If (INT(number) = number) Then
End
If (INT(number)/number = 1) Then
End
If (TypeName(number) = "Integer") Then
End
Option Explicit
Public Sub testing()
Debug.Print AddTwoNumberStrings("2352362", "74747")
End Sub
Public Function AddTwoNumberStrings( _
ByVal sString1 As String, _
ByVal sString2 As String) As String
Dim aDigits1 As Variant
Dim aDigits2 As Variant
Dim lupper As Long
Dim sResult As String
sString1 = VBA.StrReverse(sString1)
sString2 = VBA.StrReverse(sString2)
If (Len(sString2) > Len(sString1)) Then
sString1 = sString1 & String(Len(sString2) - Len(sString1), "0")
Else
sString2 = sString2 & String(Len(sString1) - Len(sString2), "0")
End If
aDigits1 = SplitTextNumberToArray(sString1)
aDigits2 = SplitTextNumberToArray(sString2)
AddTwoNumberStrings = AddTwoDigitArrays(aDigits1, aDigits2)
End Function
Public Function AddTwoDigitArrays( _
ByVal aDigits1 As Variant, _
ByVal aDigits2 As Variant) As String
Dim sResult As String
Dim aResults As Variant
Dim lupper As Long
Dim ipos As Integer
Dim iaddone As Integer
lupper = UBound(aDigits1)
ReDim aResults(lupper)
iaddone = 0
For ipos = 0 To lupper
sResult = VBA.Val(aDigits1(ipos)) + VBA.Val(aDigits2(ipos)) + iaddone
If (Len(sResult) > 1) Then
iaddone = 1
Else
iaddone = 0
End If
aResults(ipos) = Right(sResult, 1)
Next ipos
If (iaddone = 1) Then
ReDim Preserve aResults(lupper + 1)
aResults(lupper + 1) = 1
End If
AddTwoDigitArrays = VBA.StrReverse(VBA.Join(aResults, ""))
End Function
Public Function SplitTextNumberToArray( _
ByVal sNumberText As String) As Variant
Dim aDigits As Variant
aDigits = VBA.Split(VBA.StrConv(sNumberText, 64), Chr(0))
ReDim Preserve aDigits(Len(sNumberText) - 1)
SplitTextNumberToArray = aDigits
End Function
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext