VB.NET 2005,已經(jīng)實現(xiàn)了continue語法,具體是這樣操作:
成都創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的雁塔網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
如果 Continue 語句在 Do...Loop 循環(huán)中,請將該語句更改為 Continue Do。
如果 Continue 語句在 For...Next 循環(huán)中,請將該語句更改為 Continue For。
如果 Continue 語句在 While...End While 循環(huán)中,請將該語句更改為 Continue While。
否則,請移除 Continue 語句。
用法:
For i As Integer = 0 To 100
' If i = 50 跳過 Console.Writeline statement
If i = 50 Then Continue For
Console.WriteLine(i.ToString)
Next
' Do While using Continue statement.
Dim ii As Integer = 1
Do While ii 100
ii += 1
' If ii = 50 跳過 Console.Writeline statement
If ii = 50 Then Continue Do
Console.WriteLine(ii.ToString)
Loop
' While using Continue statement.
Dim iii As Integer = 1
While iii 100
iii += 1
' If iii = 50 跳過 Console.Writeline statement
If iii = 50 Then Continue While
Console.WriteLine(iii.ToString)
End While
DT.Rows.ToString未必是指結(jié)果集中的所有數(shù)據(jù),也許只是一行中所有的,或是一列中所有的
保險起見,可以一格格枚舉
dim a as boolean=true
Dim row As DataRow
For Each row In DT.Rows
Dim column As DataColumn
For Each column In DT.Columns
if row(column).contains("Agree") then a=false
Next column
Next row
if a then
Me.rblAgReject.Items(0).Enabled = False
else
Me.rblAgReject.Items(0).Enabled = True
end if
在VB.NET中VB.NET CASE語句就是比較常用的一種,下面是詳細(xì)的介紹和代碼的演示:
1、可以用 Select...Case 語句來替換 If...Then...Else 語句,所不同的是If 和 ElseIf 語句可在每個語句中計算不同的表達式,而 Select 語句對單個表達式只計算一次,然后將其和不同的值比較。
Function?bonus(ByVal?performance?As?Integer,?_??ByVal?salary?As?Decimal)?As?Decimal??
Select?performance??
Case?1??
Return?salary?*?0.1??
Case?2??
Return?salary?*?0.3??
Case?3??
Return?salary?*?0.7??
Case?4??
Return?salary?*?0.9??
Case?5??
Return?salary?*?1.2??
End?Select??
End?Function
2、VB.NET Case語句可包含多個值和某個范圍的值,代碼案例如下:
Function?bonus(ByVal?performance?As?Integer,?_??ByVal?salary?As?Decimal)?As?Decimal??
Select?performance??
Case?1??
Return?salary?*?0.1??
Case?2,3??
Return?salary?*?0.3??
Case?3?To?7??
Return?salary?*?0.7??
Case?8?To?9??
Return?salary?*?0.9??
Case?Is?=?15??
Return?salary?*?1.2??
Case?Else??
Return?0??
End?Select??
End?Function
Dim Cnn As New Data.OleDb.OleDbConnection
Dim DbAdapter As New Data.OleDb.OleDbDataAdapter
Dim Cmd As New Data.OleDb.OleDbCommand
Dim dsAll As New Data.DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\webapp\test\web.mdb"
Cmd.Connection = Cnn
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'插入
Cmd.CommandText = "insert into main (about) values ('" + TextBox1.Text + "')"
UpdateTable()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
'修改
Dim ids As Integer
ids = 1
Cmd.CommandText = "update main set about='" + TextBox1.Text + "' where id=" + ids.ToString()
UpdateTable()
End Sub
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
'刪除
Dim ids As Integer
ids = 1
Cmd.CommandText = "delete from main where id=" + ids.ToString()
UpdateTable()
End Sub
Public Sub UpdateTable()
Dim Trans As Data.OleDb.OleDbTransaction
Try
Cnn.Open()
Trans = Cnn.BeginTransaction()
Try
Cmd.Transaction = Trans
Cmd.ExecuteNonQuery()
Trans.Commit()
Catch
Trans.Rollback()
Finally
If (Cnn.State = System.Data.ConnectionState.Open) Then
Cnn.Close()
End If
End Try
Catch
'error message
End Try
End Sub
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
'顯示
Cmd.CommandText = "select id, about from main"
DbAdapter.SelectCommand = Cmd
DbAdapter.Fill(dsAll, "table1")
If (dsAll.Tables("table1").Rows.Count 0) Then
TextBox1.Text = dsAll.Tables("table1").Rows(0)("about")
Else
TextBox1.Text = ""
End If
End Sub
網(wǎng)站欄目:vb.net常用語句 vbnet using
當(dāng)前URL:http://jinyejixie.com/article2/ddccgic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、網(wǎng)站排名、定制網(wǎng)站、域名注冊、網(wǎng)站策劃、品牌網(wǎng)站設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)