Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名注冊、虛擬空間、營銷軟件、網(wǎng)站建設(shè)、廣元網(wǎng)站維護(hù)、網(wǎng)站推廣。
Dim a(15) As Integer
Dim i As Integer
Dim tmpStr As String
Randomize()
For i = 0 To a.Length - 1
a(i) = Int(100 * Rnd() + 1)
Next
TextBox1.Text = ""
tmpStr = ""
For i = 0 To a.Length - 1
tmpStr = tmpStr a(i) " "
'在Textbox中每行顯示5個
If (i + 1) Mod 5 = 0 Then
TextBox1.AppendText(tmpStr vbCrLf)
tmpStr = ""
End If
Next
End Sub
'''這個函數(shù)功能就是用來把數(shù)組轉(zhuǎn)為string的格式'''如byte()={1,2,3,4,5,6}轉(zhuǎn)化后變?yōu)?,1,2,3,4,5,6,"Function ByteArrayToString(bytes() As Byte) As String Dim s As String = "" For i As Integer = 0 To bytes.Length s = Convert.ToString(bytes(i)) "," Next Return “," sEnd Function Sub Search()Dim a as byte()={1,2,3,4,5,6}
Dim b as byte()={2,3,4}
Dim astr As String = ByteArrayToString(a)Dim bstr As String = ByteArrayToString(b)Dim index As Integer = astr.IndexOf(bstr) '這個index就是b數(shù)組在a數(shù)組的位置,下標(biāo)從0開始,不過記得處理下逗號,因?yàn)檫@時候是字符串。'''如果index小于0說明沒有匹配內(nèi)容End Sub 現(xiàn)在說明下ByteArrayToString為什么要在字符串開頭加個",",如果不加,可能出現(xiàn)a="1,23,4,5,6,", b="3,4,5,",結(jié)果導(dǎo)致查詢位置錯誤,匹配了a的位置
先把strA排序,
ind = 2
if len(strA) = 0 then return
strB(1) = strA(1)
for each s in strA
if (strA(ind) strA(ind - 1) then
count = 0
strB(ind) = strA(ind)
else
strB(ind) = strA(ind - 1)
end if
ind = ind + 1
next s
vb語法忘了。。。大概是這么個意思吧。。。。 排序N LOG N,后面是線性的N,所以總共是NLOGN
array(2,2)是多維數(shù)組的訪問方式,其數(shù)組的定義和初始化方法為:
Dim?array?As?Integer(,)?=?{{1,?2,?3},?{4,?5,?6}}
每一行的元素數(shù)量是固定且相等的。
array(2)(2)是交錯數(shù)組(即數(shù)組的數(shù)組)的訪問方式。也就是,你有一個數(shù)組,這個數(shù)組的每個元素也是數(shù)組。其數(shù)組的定義和初始化方法為:
Dim?array?As?Integer()()?=?{New?Integer()?{1,?2,?3},?New?Integer()?{4,?5,?6,?7,?8}}
由于每個元素是獨(dú)立的數(shù)組,所以交錯數(shù)組每一行的元素數(shù)量不固定,且可以不等。
新建一個類,然后使用類的實(shí)例來創(chuàng)建數(shù)組。
下面代碼放在申明處,類的里面,比如Class Form1的下面
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘(分隔線,你懂的)’’’’’’’’’’’’’’’’’’’’’
Dim person() As New member
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘(分隔線,你懂的)’’’’’’’’’’’’’’’’’’’’’
下面一段的在該文件的最下面插入
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘(分隔線,你懂的)’’’’’’’’’’’’’’’’’’’’’
Class member
Dim name As string
Dim male As Boolean '這里True表示男,F(xiàn)alse表示女
Dim age As Integer
Dim birthym As Long
End Class
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘(分隔線,你懂的)’’’’’’’’’’’’’’’’’’’’’
然后如果你想要調(diào)用一個年齡,比如第一個人的,就用
person(0).age
來表示
That's all
你只是定義了一個對象,類而已
首先要給對象設(shè)置變量,這個還不是數(shù)組
Public class As Single的class 應(yīng)該是關(guān)鍵字請換一個名字
Dim KidsX(1 to 100) as kids
KidsX(1).classx=1
KidsX(1).grade=1
KidsX(1).name=”張某"
KidsX(2).classx=1
KidsX(2).grade=2
KidsX(2).name=”王某"
……