vb.net基本语句,VB常用语句

VB.NET语句中continue while的用法

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

vb.net 关于循环语句

我写了一段代码,注意你读取的方法,我改进了一下 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注意:这样的代码是倒序的,第一个文本框显示的是最后一个文件的内容!请酌情处理!

vB.Net if 语句

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

高分求.net里vb语法操作数据库基本语句

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://ybzwz.com/article/hedsdg.html