Private Sub Command1-Click() A=Val(Text1.Text):B=Val(Text2.Text) For M=A To

 我来答
wngmae
2010-12-25 · TA获得超过1297个赞
知道小有建树答主
回答量:471
采纳率:0%
帮助的人:462万
展开全部
下面是根据你的程序改起来的,改动的地方就是把Form_load函数中的40个双引号去掉
Option Explicit

Option Base 1
Const num = 10
Dim a(num) As Single, b(num) As Single, c(num) As Single
Dim x As Single, m As Single
Dim sum As Single, i As Integer

Private Sub Command1_Click()
sum = 0
For i = 1 To num
c(i) = ((a(i) - 60) / 10 + 1) * b(i)
sum = sum + c(i)
Next i

x = sum / m
Print "Text00.Text"; x
End Sub

Private Sub Form_Load()
a(1) = Val(Text1.Text) '各科成绩
a(2) = Val(Text2.Text)
a(3) = Val(Text3.Text)
a(4) = Val(Text4.Text)
a(5) = Val(Text5.Text)
a(6) = Val(Text6.Text)
a(7) = Val(Text7.Text)
a(8) = Val(Text8.Text)
a(9) = Val(Text9.Text)
a(10) = Val(Text10.Text)
b(1) = Val(Text11.Text) '各科学分
b(2) = Val(Text12.Text)
b(3) = Val(Text13.Text)
b(4) = Val(Text14.Text)
b(5) = Val(Text15.Text)
b(6) = Val(Text16.Text)
b(7) = Val(Text17.Text)
b(8) = Val(Text18.Text)
b(9) = Val(Text19.Text)
b(10) = Val(Text20.Text)
m = Val(Text0.Text) '总学分
End Sub

============================================
下面是我给你写的程序,你可以和你的程序比较一下孰优孰劣
窗体上左上角放一个TextBox和右边放一个按钮就可以了,不需要象你那样放21个TextBox
Option Explicit

Option Base 1
Const Total = 10

Private Sub Command1_Click()
Dim Sum As Single, Score(Total) As Single, Credit(Total) As Single
Dim i As Integer, SumCredit As Integer
For i = 1 To Total
Score(i) = (Val(Text1(i - 1).Text) - 60) / 10 + 1
Credit(i) = Val(Text1(i + Total - 1).Text)
Sum = Sum + Score(i) * Credit(i)
SumCredit = SumCredit + Credit(i)
Next i

MsgBox "平均学分:" & Format(Sum / SumCredit, "0.00")
End Sub

Private Sub Form_Load()
Dim i As Integer
Text1(0).Text = 90
For i = 0 To Total - 1
If i <> 0 Then
Load Text1(i)
Text1(i).Left = Text1(0).Left
Text1(i).Top = Text1(i - 1).Top + Text1(0).Height + 100
Text1(i).Visible = True
Text1(i).Text = Int(Rnd * 60) + 35
End If
Load Text1(i + Total)
Text1(i + Total).Left = Text1(0).Left + Text1(0).Width + 400
Text1(i + Total).Top = Text1(i).Top
Text1(i + Total).Visible = True
Text1(i + Total).Text = Int(Rnd * 5) + 1
Next
End Sub
=========================================
我觉得,你的程序的一个闪光点就是
c(i) = ((a(i) - 60) / 10 + 1) * b(i)
这一句.如果这句是你自己写的,那证明你还是很有想法的
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式