前者是二維矩形數(shù)組,即傳統(tǒng)的二維數(shù)組,后者是交錯(cuò)數(shù)組.
創(chuàng)新互聯(lián)公司是一家專注于成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)與策劃設(shè)計(jì),思明網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)十年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:思明等地區(qū)。思明做網(wǎng)站價(jià)格咨詢:028-86922220
有時(shí),應(yīng)用程序中的數(shù)據(jù)結(jié)構(gòu)是兩維的但不是矩形。例如,一個(gè)月份的數(shù)組,其每個(gè)元素又是天數(shù)的數(shù)組。由于不同的月份有不同的天數(shù),元素不能構(gòu)成一個(gè)矩形的兩維數(shù)組。在這種情況下,可以使用交錯(cuò)數(shù)組而不是多維數(shù)組。
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 配對(duì),一般要先用#Const 定義條件編譯器常量
'以下是例子
Module Module1
#Const i = 60
Sub Main()
#If i 30 Then
Console.WriteLine("???") '如果用#Const定義了i,該句語(yǔ)句才會(huì)執(zhí)行,假如用的是private i as integer=60定義,該語(yǔ)句不會(huì)被執(zhí)行
#End If
End Sub
End Module
不一樣的,主要的關(guān)鍵字差不多,語(yǔ)法有一些有變化
vb.net與vb語(yǔ)法的一個(gè)很大不同——oop設(shè)計(jì)
例如
sMyString = Mid(sMyString,3,4)
現(xiàn)在,它可以被替換為:
sMyString = sMyString.substring(3,4)
你這個(gè)問(wèn)題是這樣的呀:
因?yàn)槟爿斎肓?0+10以后你為了結(jié)束是不是又打了個(gè)回車?那就是\n了,
但是這個(gè)\n現(xiàn)在被存在stdin的緩沖區(qū)里沒(méi)有被取走,所以當(dāng)你要輸入Y或者N的時(shí)候,again將stdin的\n取走了,而沒(méi)有給你輸入的機(jī)會(huì)。
所以你應(yīng)該是
printf("Please enter Y or N\n");
scanf("%c", again); //取走\(yùn)n
scanf("%c",again); //記錄Y或者N
這樣就可以了。
你這是vb.net的代碼,vb中不允許那么寫(xiě):
Dim
strdx()
As
String
=
{"0",
"0",
"0"}
'定義個(gè)數(shù)組,從后面的值能看的出最大下標(biāo)是2,也就是strdx(0),strdx(1)和strdx(2),3個(gè)的默認(rèn)值都為0
Dim
calcount1
As
String
=
"0"
'定義個(gè)字符串變量
Dim
calcount2
As
String
=
"0"
Dim
strvalue
As
Boolean
=
False
'定義strvalue為bool值,改類型變量只有true和false
2種值
If
strdx(0)
=
"0"
Then
TextBox1.Text
=
strdx(0)
"."
這是字符串連接符號(hào),和"+"的區(qū)別是,他把左右2邊的內(nèi)容直接連接的,而"+"可能會(huì)編程運(yùn)算符,例如
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
'
這里開(kāi)始是分支語(yǔ)句
Case
"+"
TextBox1.Text
=
Str(Val(strdx(1))
+
Val(strdx(0)))
網(wǎng)頁(yè)名稱:.netvb語(yǔ)法 netvbnet
分享URL:http://jinyejixie.com/article16/hehigg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、軟件開(kāi)發(fā)、網(wǎng)站設(shè)計(jì)公司、企業(yè)網(wǎng)站制作、網(wǎng)站導(dǎo)航、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容