Private Sub Form_Click()
目前創(chuàng)新互聯(lián)已為上1000+的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)頁空間、網(wǎng)站托管、服務(wù)器租用、企業(yè)網(wǎng)站設(shè)計、臨渭區(qū)網(wǎng)站維護(hù)等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
Dim a(3) As Integer
Dim m As Boolean
m = True
For i = 0 To 3
a(i) = 1
Next i
For i = 0 To UBound(a)
If a(i) 1 Then
m = False
Exit For
End If
Next i
If m = True Then
Print "全部符合"
Else
Print "不全部符合"
End If
End Sub
Dim?str?As?String?=?"",?temp,?n?As?Integer
Dim?str1?As?String?=?"12,45,2,9,41,31,66,83,2,1,-9,-91,-21"
Dim?a()?As?String?=?Split(str1,?",")
For?i?=?1?To?UBound(a)?Step?1
a(i)?=?Val(a(i))
Next
temp?=?0
n?=?0
For?i?=?1?To?UBound(a)
If?a(i)??temp?Then
temp?=?a(i)
End?If
If?a(i)??0?Then
n?=?n?+?1
End?If
Next
str?=?str??"正數(shù)的個數(shù)為?"??n
str?=?str??"最大元素的下標(biāo)為?"
For?i?=?1?To?UBound(a)
If?a(i)?=?temp?Then
str?=?str??i??"?"
End?If
Next
TextBox6.Text?=?str
Dim?str?As?String?=?"",?temp,?n?As?Integer
Dim?str1?As?String?=?"12,45,2,9,41,31,66,83,2,1,-9,-91,-21"
Dim?a()?As?String?=?Split(str1,?",")
For?i?=?1?To?UBound(a)?Step?1
a(i)?=?Val(a(i))
Next
temp?=?0
n?=?0
For?i?=?1?To?UBound(a)
If?a(i)??temp?Then
temp?=?a(i)
End?If
If?a(i)??0?Then
n?=?n?+?1
End?If
Next
str?=?str??"正數(shù)的個數(shù)為?"??n
str?=?str??"最大元素的下標(biāo)為?"
For?i?=?1?To?UBound(a)
If?a(i)?=?temp?Then
str?=?str??i??"?"
End?If
Next
TextBox6.Text?=?str
每行的數(shù)字個數(shù)不同,你說的這是不規(guī)則數(shù)組,解決方案如下:
Dim b As String = ""
Dim a As Integer()() = New Integer(9)() {}
a(0) = New Integer() {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
a(1) = New Integer() {0, 3, 4, 5}
a(2) = New Integer() {0, 4, 5, 6, 7}
a(3) = New Integer() {0, 6, 5, 8, 9, 1}
a(4) = New Integer() {0, 2, 5, 1, 7}
a(5) = New Integer() {0, 4, 2, 6, 7, 3}
a(6) = New Integer() {0, 4, 5, 3, 2}
a(7) = New Integer() {0, 4, 1, 6, 2, 8, 5, 3}
a(8) = New Integer() {0, 4, 9, 6, 3, 5, 7}
a(9) = New Integer() {0, 1, 5, 9, 7, 6, 2, 4, 3, 8}
For i As Integer = 0 To a.GetUpperBound(0)
b = "第" i + 1 "行有" a(i).GetUpperBound(0) + 1 "個數(shù)" vbCrLf
Next
MessageBox.Show(b)
vb.net已經(jīng)去掉了控件數(shù)組這個類,不過有個代替該方式的一個屬性:Tag,你可以把這些關(guān)聯(lián)的Tag屬性設(shè)置為同一標(biāo)記,如:a。然后遍歷所有的checkbox并且tag為a的則選定:Protected Sub chkAll_Click() For Each ctl As Control In Me.Controls ''如果checkbox在一個容器里,比如groupbox,那可以用groupbox.controls
If ctl.GetType().Name.ToLower() = "checkbox" Then
CType(ctl, CheckBox).Checked = CheckBox3.Checked
End If
NextEnd Sub