vb.net的基础语法,VBNET编程宝典

VB.NET编程语法

你这是vb.net的代码,vb中不允许那么写:

在易县等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站建设、成都网站设计 网站设计制作专业公司,公司网站建设,企业网站建设,品牌网站制作,营销型网站建设,外贸网站建设,易县网站建设费用合理。

Dim

strdx()

As

String

=

{"0",

"0",

"0"}

'定义个数组,从后面的值能看的出最大下标是2,也就是strdx(0),strdx(1)和strdx(2),3个的默认值都为0

Dim

calcount1

As

String

=

"0"

'定义个字符串变量

Dim

calcount2

As

String

=

"0"

Dim

strvalue

As

Boolean

=

False

'定义strvalue为bool值,改类型变量只有true和false

2种值

If

strdx(0)

=

"0"

Then

TextBox1.Text

=

strdx(0)

"."

这是字符串连接符号,和"+"的区别是,他把左右2边的内容直接连接的,而"+"可能会编程运算符,例如

2

3

=

"23"

2

+

3

=

5

ElseIf

strvalue

=

False

Then

strdx(0)

=

strdx(0)

"0"

TextBox1.Text

=

strdx(0)

"."

strvalue

=

True

Else

strdx(0)

=

strdx(0)

"0"

TextBox1.Text

=

strdx(0)

Select

Case

calcount1

'

这里开始是分支语句

Case

"+"

TextBox1.Text

=

Str(Val(strdx(1))

+

Val(strdx(0)))

高分求.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 中,#if 是什么语法?

#If...Then...#Else 指令

根据条件编译选定的 Visual Basic 代码块,需要有#Const 配对,一般要先用#Const 定义条件编译器常量

'以下是例子

Module Module1

#Const i = 60

Sub Main()

#If i 30 Then

Console.WriteLine("???") '如果用#Const定义了i,该句语句才会执行,假如用的是private i as integer=60定义,该语句不会被执行

#End If

End Sub

End Module


新闻标题:vb.net的基础语法,VBNET编程宝典
网站链接:http://lszwz.com/article/hcispi.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款