○分類 |
VBA |
○解説
- モジュールを新規作成して、以下のコードを入力して保存します。
Option Compare Database
Public Function RoundUp(x As Currency, s As Integer) As Currency
Dim w As Currency
t = 10 ^ Abs(s)
If x > 0 Then
If s > 0 Then
RoundUp = -Int(-x * t) / t
Else
RoundUp = -Int(-x / t) * t
End If
Else
If s > 0 Then
RoundUp = Int(x * t) / t
Else
RoundUp = Int(x / t) * t
End If
End If
End Function
Public Function RoundDown(x As Currency, s As Integer) As Currency
Dim t As Currency
t = 10 ^ Abs(s)
If x > 0 Then
If s > 0 Then
RoundDown = Int(x * t) / t
Else
RoundDown = Int(x / t) * t
End If
Else
If s > 0 Then
RoundDown = -Int(-x * t) / t
Else
RoundDown = -Int(-x / t) * t
End If
End If
End Function
これで、
RoundUp([数値],[桁数])
RoundDown([数値],[桁数])
が使えるはずです。試してみて下さい。
(Netwanderer)
|
○私的意見
|
○関連リンク
書き込みはまだありません。
|
http://www.accessclub.jp/bibouroku/017.html
Comments are closed.