For example, the following code would fail the late binding Option Strict test:
Dim test3 As Object = Split("1,2,3", ",")
MsgBox(test3(0))
However, the following code would pass:
Dim test3() As Object = Split("1,2,3", ",")
MsgBox(test3(0))
Likewise, the following code would fail the conversion Option Strict test:
Dim i As Integer
TextBox1.Text = "34"
i = 360 * (CLng(TextBox1.Text) / 100)
MsgBox(i)
In cases such as this, you'd use the CType function to explicitly convert the result:
Dim i As Integer
TextBox1.Text = "34"
i = CType(360 * (CLng(TextBox1.Text) / 100), Integer)
MsgBox(i)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.