ユーザー定義書式(メモ) | てっちゅーのお役立ち日記

てっちゅーのお役立ち日記

仕事、健康、家庭、教育、趣味、コンピューターなど

今日も何処かで誰かの役に立つ情報を不定期でアップしていく予定です。

VB.Netでユーザー定義書式を使用して数値を表示


環境:VB.Net2008
ツールボックスからButton1を追加しておく


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


'表示結果 Format(12345.6789, "#,###")=12,346
Debug.Print("Format(12345.6789, ""#,###"")=" & Format(12345.6789, "#,###"))


'表示結果 Format(12345.6789, "#,###.##")=12,345.68
Debug.Print("Format(12345.6789, ""#,###.##"")=" & Format(12345.6789, "#,###.##"))


'表示結果 Format(12345.6789, "#,###.00")=12,345.68
Debug.Print("Format(12345.6789, ""#,###.00"")=" & Format(12345.6789, "#,###.00"))


'表示結果 Format(12345.6789, "#,###.#####")=12,345.6789
Debug.Print("Format(12345.6789, ""#,###.#####"")=" & Format(12345.6789, "#,###.#####"))


'表示結果 Format(12345.6789, "#,###.00000")=12,345.67890
Debug.Print("Format(12345.6789, ""#,###.00000"")=" & Format(12345.6789, "#,###.00000"))


'表示結果 Format(12345.6789, "#,##0")=12,346
Debug.Print("Format(12345.6789, ""#,##0"")=" & Format(12345.6789, "#,##0"))


'表示結果 Format(12345.6789, "#,##0.00")=12,345.68
Debug.Print("Format(12345.6789, ""#,##0.00"")=" & Format(12345.6789, "#,##0.00"))


'表示結果 Format(12345.6789, "#")=12346
Debug.Print("Format(12345.6789, ""#"")=" & Format(12345.6789, "#"))


'表示結果 Format(12345.6789, "0")=12346
Debug.Print("Format(12345.6789, ""0"")=" & Format(12345.6789, "0"))


'表示結果 Format(12345.6789, "0.00%")=1234567.89%
Debug.Print("Format(12345.6789, ""0.00%"")=" & Format(12345.6789, "0.00%"))


End Sub