「VB.net」ToStringで数値を文字列に変換する

書式
Public Overrides Function ToString () As String
数値(Integer)を文字列に変換する

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Sub Main()
'Integer型文字列変数の宣言
Dim cftA As Integer = 5678
' 数値を文字列に変換
Dim cftB As String = cftA.ToString
'データ型を調べる
Console.WriteLine(cftB)
Console.WriteLine(VarType(cftB))
Console.ReadKey()
End Sub
End Module
Module Module1 Sub Main() 'Integer型文字列変数の宣言 Dim cftA As Integer = 5678 ' 数値を文字列に変換 Dim cftB As String = cftA.ToString 'データ型を調べる Console.WriteLine(cftB) Console.WriteLine(VarType(cftB)) Console.ReadKey() End Sub End Module
Module Module1

    Sub Main()

        'Integer型文字列変数の宣言
        Dim cftA As Integer = 5678

        ' 数値を文字列に変換
        Dim cftB As String = cftA.ToString

        'データ型を調べる
        Console.WriteLine(cftB)
        Console.WriteLine(VarType(cftB))

        Console.ReadKey()

    End Sub

End Module

結果
5678
8

VB.net

Posted by arkgame