「VB.NET」数値型(Single, Integer, Long, Double)から文字列型(String)に変換する

書式
Dim 変数名1 As Single =値2
変数名1.ToString()
Dim 変数名2 As Integer = 値2
変数名2.ToString()
使用例

Module Module1

    Public Sub Main()

        '数値(Single型)を文字列に変換
        Dim cftA As Single = 456.78F
        Dim kk = cftA.ToString()
        Console.WriteLine("Single型->文字列: " & kk)

        '数値(Double型)を文字列に変換
        Dim cftD As Double = 63.12
        Dim tt = cftD.ToString()
        Console.WriteLine("Double型->文字列: " & tt)

        '数値(Integer型)を文字列に変換
        Dim cftB As Integer = 789
        Dim rr = cftB.ToString()
        Console.WriteLine("Integer型->文字列: " & rr)

        '数値(Long型)を文字列に変換
        Dim cftC As Long = 567L
        Dim ss = cftC.ToString()
        Console.WriteLine("Long型->文字列: " & ss)

        Console.ReadKey()
    End Sub

End Module

実行結果
Single型->文字列: 456.78
Double型->文字列: 63.12
Integer型->文字列: 789
Long型->文字列: 567

VB.net

Posted by arkgame