在VB中,可以使用以下方法进行数据类型转换:
Dim str As String = "123"
Dim num As Integer = CType(str, Integer)
Dim obj As Object = "Hello"
Dim str As String = DirectCast(obj, String)
Dim num1 As Double = 3.14
Dim num2 As Integer = CInt(num1)
Dim str As String = "123"
Dim num As Integer = Integer.Parse(str)
需要注意的是,在进行数据类型转换时,要确保转换是安全的,避免出现数据类型不匹配或溢出的情况。