vb.net 统计数组中相同数字的个数
Private Sub Form_Click()
目前创新互联已为上1000+的企业提供了网站建设、域名、网页空间、网站托管、服务器租用、企业网站设计、临渭区网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
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
vb.net用文本框输入数组的所有元素,数值之间用逗号分隔,统计数组中正数的个数,并显示最大值的元素下标
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 "正数的个数为 " n
str = str "最大元素的下标为 "
For i = 1 To UBound(a)
If a(i) = temp Then
str = str i " "
End If
Next
TextBox6.Text = str
vb.net数组
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 "正数的个数为 " n
str = str "最大元素的下标为 "
For i = 1 To UBound(a)
If a(i) = temp Then
str = str i " "
End If
Next
TextBox6.Text = str
VB.net中如何求出2维数组,每个维度上的值得个数
每行的数字个数不同,你说的这是不规则数组,解决方案如下:
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 "个数" vbCrLf
Next
MessageBox.Show(b)
vb.net 数组
vb.net已经去掉了控件数组这个类,不过有个代替该方式的一个属性:Tag,你可以把这些关联的Tag属性设置为同一标记,如: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
网页名称:vb.net统计数组 c语言数组统计
文章网址:http://scyingshan.cn/article/hghjeo.html