大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
为什么一定要用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