vb.net数组中统计 vbs数组
VB中怎样统计一组数中每个数字出现的个数
Private Sub Command3_Click()
成都创新互联总部坐落于成都市区,致力网站建设服务有成都网站设计、成都网站建设、网络营销策划、网页设计、网站维护、公众号搭建、成都小程序开发、软件开发等为企业提供一整套的信息化建设解决方案。创造真正意义上的网站建设,为互联网品牌在互动行销领域创造价值而不懈努力!
Dim a%(1 to 100), b%(0 to 9)
For i = 1 To 100
a(i) = Int(Rnd * 100+1)
Print a(i);
If i Mod 10 = 0 Then
End If
_____________________上面是随机产生100个整数~
for i=i to 100 then
j=a(i) mod 10-----这步:整除10的与余数保存在j这个函数里
b(j)=j----这步:因为定义里是0到9所以只需把余数存在对应的数组b(余数)里就行了~
next i
print "个位是0的数有" b(0) ”个”
print "个位是1的数有" b(1) ”个”
print "个位是2的数有" b(2) ”个”
print "个位是3的数有" b(3) ”个”
print "个位是4的数有" b(4) ”个”
print "个位是5的数有" b(5) ”个”
print "个位是6的数有" b(6) ”个”
print "个位是7的数有" b(7) ”个”
print "个位是8的数有" b(8) ”个”
print "个位是9的数有" b(9) ”个”
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 统计数组中相同数字的个数
Private Sub Form_Click()
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数组中统计 vbs数组
网页路径:http://myzitong.com/article/dodpieh.html