这篇文章给大家分享的是有关VB.NET语法规则有哪些的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
VB.NET语法规则实例1:
同 Integer 类型的变量比较
Public Class CompareForm
Private Sub Button1_Click
(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles Button1.Click
Dim A As Integer = 10
Dim B As Integer = 20
If A <= B Then
MessageBox.Show("提示:A<=B")
Else
MessageBox.Show("提示:A>B")
End If
End Sub
End Class
VB.NET语法规则实例2:
Boolean变量的比较
ublic Class LogicForm
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e
As System.EventArgs) Handles
Button1.Click
Dim a As Boolean = True
Dim b As Boolean = False
If a And b = True Then ''
和If a And b Then相同
MessageBox.Show("提示:a和b都是True ")
Else
MessageBox.Show("提示:a和b有一个不是True ")
End If
End Sub
End Class
VB.NET语法规则实例3:
同String类型变量比较 String和Integer不同变量的比较
Public Class StrForm
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e
As System.EventArgs) Handles
Button1.Click
Dim str1, str2 As String
str1 = "Hello"
str2 = "World"
MessageBox.Show("提示:" &
str1 + " " + str2) ''Message
Box.show(str1 & " " & str2)也可以
End Sub
Private Sub Button2_Click(ByVal
sender As System.Object, ByVal e
As System.EventArgs) Handles
Button2.Click
Dim z As Integer
Dim x As String = " 100"
z = 50
MessageBox.Show(x & z) ''
MessageBox.Show(x + z)
End Sub
End Class
感谢各位的阅读!关于“VB.NET语法规则有哪些”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!