OpenOffice.org/LibreOffice BASICでFloor関数を探しても見当たらなかったので泣く泣く自作してみた。
作り終わってから実はInt()があってそれで十分だって気づいたから、折角書いたけど使わないんだなぁ(T_T)
'
' Foor関数。Int()で困らなかったのでじつは不要
'
Function Fn_Floor( ByVal fpReal As Double, Optional ByVal ipBase As Long ) As Long
Dim iBase As Long
If isMissing( ipBase ) Then
iBase = 1
Else
iBase = ipBase
EndIf
If ipBase <= 0 Then
Msgbox "Fn_Floor()の第2引数は1以上の整数である必要があります。第2引数=[" & ipBase & "]"
Fn_Floor = 0
Exit Function
EndIf
If fpReal >=0 Then
If CLng(fpReal/iBase) *iBase > fpReal Then
Fn_Floor = CLng(fpReal/iBase) * iBase -iBase
Exit Function
Else
Fn_Floor = CLng(fpReal/iBase) * iBase
Exit Function
EndIf
Else ' fpReal<0
If CLng(fpReal/iBase) * iBase > fpReal Then
Fn_Floor = CLng(fpReal/iBase) * iBase -iBase
Exit Function
Else
Fn_Floor = CLng(fpReal/iBase) * iBase
Exit Function
EndIf
EndIf
Fn_Floor = 0
End Function ' Fn_Floor
*「Syntax Highlighter for WordPress」というプラグインを利用してコードを表示しています。他にいいのがあればぜひ教えてね。