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
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
在VB.NET中VB.NET CASE语句就是比较常用的一种,下面是详细的介绍和代码的演示:
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
网站栏目:vb.net常用语句 vbnet using
当前URL:https://www.cdcxhl.com/article2/ddccgic.html
成都网站建设公司_创新互联,为您提供建站公司、网站排名、定制网站、域名注册、网站策划、品牌网站设计
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联