你這是vb.net的代碼,vb中不允許那么寫:
在易縣等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計 網(wǎng)站設(shè)計制作專業(yè)公司,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站制作,營銷型網(wǎng)站建設(shè),外貿(mào)網(wǎng)站建設(shè),易縣網(wǎng)站建設(shè)費用合理。
Dim
strdx()
As
String
=
{"0",
"0",
"0"}
'定義個數(shù)組,從后面的值能看的出最大下標(biāo)是2,也就是strdx(0),strdx(1)和strdx(2),3個的默認(rèn)值都為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)
"."
這是字符串連接符號,和"+"的區(qū)別是,他把左右2邊的內(nèi)容直接連接的,而"+"可能會編程運算符,例如
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)))
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
#If...Then...#Else 指令
根據(jù)條件編譯選定的 Visual Basic 代碼塊,需要有#Const 配對,一般要先用#Const 定義條件編譯器常量
'以下是例子
Module Module1
#Const i = 60
Sub Main()
#If i 30 Then
Console.WriteLine("???") '如果用#Const定義了i,該句語句才會執(zhí)行,假如用的是private i as integer=60定義,該語句不會被執(zhí)行
#End If
End Sub
End Module