网站建设资讯

NEWS

网站建设资讯

vb.net的基础语法 VBNET的编程机制

VB.NET编程语法

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

创新互联公司专业为企业提供沐川网站建设、沐川做网站、沐川网站设计、沐川网站制作等企业网站建设、网页设计与制作、沐川企业网站模板建站服务,10年沐川做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

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)))

vb.net查询语法

顺序应该是先Connection的Open

con.ConnectionString = constr

con.Open()

dc = New OleDbDataAdapter(sql, constr)

另外你的SQL语句好像有点问题,表名不加单引号

高分求.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.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 update语法

其他的没法看,不过下面这句是肯定有问题的,应该连编译都过不了:

Dim querystring As String = "update 班级信息表 set 班级名称="TextBox1.Text",班级编号="TextBox2.Text""

改称这样试试:

Dim querystring As String

querystring = "update 班级信息表 set 班级名称=" chr(39) TextBox1.Text chr(39) ", 班级编号=" chr(39) TextBox2.Text chr(39)


网站题目:vb.net的基础语法 VBNET的编程机制
网址分享:http://cdweb.net/article/hpdspg.html