0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AccessのVBAで数字を3桁コンマ区切りでフォーマット

Last updated at Posted at 2023-02-04

やり方

Format(数字, "#,##0")

イミディエイトウィンドウにコピペして動作確認する用

数値

結果は『123』
?Format(123, "#,##0")
結果は『1,234』
?Format(1234, "#,##0")
結果は『1,234,567,890』
?Format(1234567890, "#,##0")
結果は『0』
?Format(0, "#,##0")
結果は『-1,000』
?Format(-1000, "#,##0")

文字列

結果は『123』
?Format("123", "#,##0")
結果は『1,234』
?Format("1234", "#,##0")
結果は『1,234,567,890』
?Format("1234567890", "#,##0")
結果は『0』
?Format("0", "#,##0")
結果は『-1,000』
?Format("-1000", "#,##0")

NULL

結果は『』(例外にならない)
?Format(NULL, "#,##0")

空文字

結果は『』(例外にならない)
?Format("", "#,##0")

『#,###』でフォーマットすると…

下記の結果は『』。

Format(0, "#,###")

0の場合は『#,###』か『#,##0』で挙動が変わる。

0の時は空文字にしたい のか あえて0を表示させたい のか で使い分け。

バージョン

Windows 10 Pro 22H2 OSビルド 19045.2546
Microsoft Access for Microsoft 365 MSO (バージョン 2212 ビルド 16.0.16026.20002) 32 ビット

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?