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