「VB.net」ToStringで数値を文字列に変換する
書式
Public Overrides Function ToString () As String
数値(Integer)を文字列に変換する
使用例
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