这篇文章将为大家详细讲解有关VB.NET语法规则是什么,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
列举了3个实例了解语法规则的规律。
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) ''MessageBox.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语法规则是什么”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。