VB.NET 2005,已經實現了continue語法,具體是這樣操作:
專注于為中小企業提供網站制作、做網站服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業阿榮免費做網站提供優質的服務。我們立足成都,凝聚了一批互聯網行業人才,有力地推動了上千家企業的穩健成長,幫助中小企業通過網站建設實現規模擴充和轉變。
如果 Continue 語句在 Do...Loop 循環中,請將該語句更改為 Continue Do。
如果 Continue 語句在 For...Next 循環中,請將該語句更改為 Continue For。
如果 Continue 語句在 While...End While 循環中,請將該語句更改為 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
我寫了一段代碼,注意你讀取的方法,我改進了一下 Imports System.IO ‘代碼窗體的最上端一定要聲明
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sr As StreamReader Dim TextBox As Control
Dim i As Integer
i = 1
For Each TextBox In Me.Controls
If TypeName(TextBox) = "TextBox" Then sr = New StreamReader("c:\save\" i ".ini", System.Text.Encoding.Default) ’注意選擇編碼方式,按你原來的方法,未設置編碼,顯示的是亂碼!路徑請按你的情況改! TextBox.Text = sr.ReadToEnd()
i += 1 End If
Next
MsgBox("已經載入" i - 1 "個文件") End Sub注意:這樣的代碼是倒序的,第一個文本框顯示的是最后一個文件的內容!請酌情處理!
DT.Rows.ToString未必是指結果集中的所有數據,也許只是一行中所有的,或是一列中所有的
保險起見,可以一格格枚舉
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
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
網頁標題:vb.net基本語句,VB常用語句
網址分享:http://vcdvsql.cn/article16/hedsdg.html
成都網站建設公司_創新互聯,為您提供響應式網站、企業網站制作、小程序開發、域名注冊、全網營銷推廣、服務器托管
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯