为什么一定要用VB.NET?用EXCEL中的VBA即可完成,如果需要,代码如下:
成都创新互联公司是专业的红古网站建设公司,红古接单;提供成都网站设计、成都网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行红古网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
Sub test()
Dim Last As Double, SUM As Double, Resault As Double, Count As Integer
Data = Range("a1:a" Cells.Find("*", , , , 1, 2).Row)
SUM = 0: Count = 0
For i = 1 To UBound(Data, 1)
If Data(i, 1) 0 Then
If Last 0 Then
SUM = SUM + Data(i, 1) - Last
Count = Count + 1
End If
Last = Data(i, 1)
End If
Next i
Resault = SUM / Count
End Sub
注:由于统计方式比较简单,要取得需要的结果并不需要将相减后的数据放入另一数组,所以没有浪费内存去生成另一个数组。
Private Sub Command1_Click()
Const count = 1 '为了方便调试,用了个常量来定义学生数量,我只用了2个,懒得输入太多数据.用常量也便于以后加人,扩充.
Dim StudentName(count), NameStr As String
Dim Student(count, 1), i As Integer
NameStr = ""
For i = 0 To count
StudentName(i) = InputBox("学生姓名", "请输入", 0)
'此处,如无意外,应该是用数组按相应序号保存学生名字,所以,你的9肯定不对的,得相应改为该学生序号,这个是字串数组,直接保存输入的字串就行了,
'用val()会转换为数字,如果输入字符,结果为0,学生名都会是0的.
Student(i, 1) = Val(InputBox("学生成绩", "请输入", 0))
If Student(i, 1) 60 Then
NameStr = NameStr StudentName(i) ":" Str(Student(i, 1))
'这里改了一下,加了个":",方便看结果.
End If
Next
MsgBox "不及格学生:" NameStr, vbOKOnly
'msgbox如果不用在表达式中,其参数不用括号的,我的VB6.0会提示出错的.
End Sub
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
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点虐
数组统计 vb 统计
本文链接:https://www.cdcxhl.com/article16/ddioedg.html
成都网站建设公司_创新互联,为您提供云服务器、品牌网站制作、定制网站、微信公众号、外贸建站、虚拟主机
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联