要将字符串转换为数字,可以使用Convert.ToInt32()
方法来将字符串转换为整数,也可以使用Convert.ToDouble()
方法来将字符串转换为浮点数。示例如下:
Dim str As String = "123"
Dim num As Integer = Convert.ToInt32(str)
Console.WriteLine(num) ' 输出:123
Dim str2 As String = "3.14"
Dim num2 As Double = Convert.ToDouble(str2)
Console.WriteLine(num2) ' 输出:3.14