7-21 学习VB.net的笔记

前端之家收集整理的这篇文章主要介绍了7-21 学习VB.net的笔记前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Dim 声明关键字

& == +xx.ToString

// 都是为加注解

//定义一个函数

Private Function 方法 As 返回数据类型

……….

End Funcation

//if … else

If 条件 Then …. Else End if

If …..ElseIf …ElseIf…Else …Endif

For……Next循环 如:

Dim intCount as Integer

For intCount=1 To 5

listData.Items.Add(“I’m item ”& intCount &”in the list”)

Next

二:

For intCount as Integer=4 To 62 Step 7

lstData.Items.Add(intCount)

Next

三:反向循环

For intCount As Integer=10 To 1 Step -1

lstData.Items.Add(intCount)

Next

四:ForEach 循环

For Each strFoler As String In _

My.Computer.FileSystem.GetDirectories("E:/")

lstDate.Items.Add(strFoler)

Next

五:Do Until Loop 循环

Dim objRandom As New Random()

Dim intRandomNumber As Integer = 0

lstDate.Items.Clear()

Do Until intRandomNumber = 10

intRandomNumber = objRandom.Next(25)

lstDate.Items.Add(intRandomNumber)

Loop

相对的Do While Loop

Dim objRandom As New Random()

Dim intRandomNumber As Integer = 0

lstDate.Items.Clear()

Do Until intRandomNumber <15

intRandomNumber = objRandom.Next(25)

lstDate.Items.Add(intRandomNumber)

Loop

提前结束循环

For Each strFoler As String In My.Computer.FileSystem.GetDirectories("E:/")

lstDate.Items.Add(strFoler)

If String.Compare(strFoler,"E:/HXH",True) = 0 Then

MessageBox.Show("循环提前结束","提示")

Exit For

End If

Next

结束For Each循环是Exit For

结束Do Unit LoopDo While Loop循环 是 Exit Do

Select Case 参数

.

.

Case Else

猜你在找的VB相关文章