Infinite opportunities? Endless problems? Limited resources? Talk to us!
Operations
Consulting
Software
Consulting
Publishing and
Training
Applied
Solutions
Excel add-ins
and tutorials
Charts Excel and VBA
Case Studies
VBA
tutorials
PowerPoint
Add-Ins
Miscellenia

Monday, December 22, 2008

VB(A) functions

There are several common functions that are useful to the VB(A) developer.  This is a preliminary list.  Some of these are available through the Excel object, but that, of course, introduces a dependency on Excel. {grin}



Function VBPermut(ByVal N As Long, ByVal R As Long) As Long
'Returns the number of permutations from N elements taken R at a time _
given by n! / (n - r)! = n * (n-1) * (n-2) * ... * (n-r+1)
Dim I As Long
VBPermut = 1
For I = N - R + 1 To N
VBPermut = VBPermut * I
Next I
End Function
Function VBCeil(ByVal x As Double) As Long
'Returns the smallest integer that is greater than or equal to the argument
If x < 0 Then VBCeil = Fix(x) Else VBCeil = -Int(-x) 'leverages Ceil(x) = -Floor(-x)
End Function
Function VBFloor(ByVal x As Double) As Long
'Returns the largest integer that is less than or equal to the argument
VBFloor = Int(x)
End Function

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home

About this site
Google
Web
This Site