「VB.net」Parseメソッドで文字列を数値に変換する
書式
Public Function VarType (VarName As Object) As VariantType
変数のデータ型の分類を含む Integer 値を返します。
使用例
Module Module1
Sub Main()
'文字列変数の宣言
Dim cftA As String = "678"
' 文字列を数値に変換
Dim cftB As Integer = Integer.Parse(cftA)
'データ型を調べる
Console.WriteLine(cftB)
Console.WriteLine(VarType(cftB))
Console.ReadKey()
End Sub
End Module
Module Module1
Sub Main()
'文字列変数の宣言
Dim cftA As String = "678"
' 文字列を数値に変換
Dim cftB As Integer = Integer.Parse(cftA)
'データ型を調べる
Console.WriteLine(cftB)
Console.WriteLine(VarType(cftB))
Console.ReadKey()
End Sub
End Module
Module Module1 Sub Main() '文字列変数の宣言 Dim cftA As String = "678" ' 文字列を数値に変換 Dim cftB As Integer = Integer.Parse(cftA) 'データ型を調べる Console.WriteLine(cftB) Console.WriteLine(VarType(cftB)) Console.ReadKey() End Sub End Module
結果
678
3
3