计算奖学金等级,输入3门成绩,输出等级,评断标准如下:(两条成立1条即可,选高不选低)
一等:(1)平均分大于95
      (2)有两门等于100,另一门不小于80
二等:(1)平均大于90
      (2)有一门100,其它2门不少于75
三等:各门不少于70Private Sub Command1_Click()
 If (Text1.Text + Text2.Text + Text3.Text) \ 3 > 95 Or ((Text1.Text = 100 And Text2.Text = 100 And Text3.Text >= 80) Or (Text3.Text = 100 And Text2.Text = 100 And Text1.Text >= 80) Or (Text1.Text = 100 And Text3.Text = 100 And Text2.Text >= 80)) Then
  Label4.Caption = "该学生获得一等奖学金!"
   ElseIf (Text1.Text + Text2.Text + Text3.Text) \ 3 > 90 Or ((Text1.Text = 100 And Text2.Text >= 75 And Text3.Text >= 75) Or (Text2.Text = 100 And Text1.Text >= 75 And Text3.Text >= 75) Or (Text3.Text = 100 And Text2.Text >= 75 And Text1.Text >= 75)) Then
      Label4.Caption = "该学生获得二等奖学金!"
       ElseIf Text1.Text >= 70 And Text2.Text >= 70 And Text3.Text >= 70 Then
         Label4.Caption = "该学生获得三等奖学金!"
          ElseIf Text1.Text < 70 And Text2.Text < 70 And Text3.Text < 70 Then Label4.Caption = "该学生不能获得奖学金!"
 End If
End SubPrivate Sub Command2_Click()
 Text1.Text = ""
 Text2.Text = ""
 Text3.Text = ""
 Label4.Caption = ""
End SubPrivate Sub Command3_Click()
 End
End Sub

解决方案 »

  1.   

    还有2张100分的送分帖也请大家关注
    http://community.csdn.net/Expert/topic/4571/4571700.xml?temp=.7152368
    http://community.csdn.net/Expert/topic/4626/4626752.xml?temp=.4085352
      

  2.   

    Private Sub Command1_Click()
            
        Dim sngSum          As Single
        Dim sngAvg          As Single
        Dim strLevel        As String
        
        sngSum = (CSng(Text1.Text) + CSng(Text2.Text) + CSng(Text3.Text))
        sngAvg = sngSum / 3
        
        If (sngAvg > 95) Or (sngSum >= 280) Then
            strLevel = "该学生获得一等奖学金!"
        ElseIf (sngAvg > 90) Or (sngSum >= 250) Then
            strLevel = "该学生获得二等奖学金!"
        ElseIf (sngSum >= 210) Then
            strLevel = "该学生获得三等奖学金!"
        Else
            strLevel = "该学生不能获得奖学金!"
        End If
        
        Label1.Caption = strLevel
        
    End Sub
      

  3.   

    a,b,c三门成绩:
    一等:(1)平均分大于95
          (2)有两门等于100,另一门不小于80
    if (a+b+c)/3>95 or _
       (a=100 and b=100 and c>=80) or _
       (a=100 and b>=80 and c=100) or _
       (a>=80 abd b=100 and c=100) then
          msgbox "一等奖"
    end if二等:(1)平均大于90
          (2)有一门100,其它2门不少于75
    if (a+b+c)/3>90 or _
       (a=100 and b>=75 and c>=75) or _
       (a>=75 and b=100 and c>=75) or _
       (a>=75 abd b>=75 and c=100) then
          msgbox "二等奖"
    end if三等:各门不少于70
    if a>70 and b>70 and c>70 then
        msgbox "三等奖"
    end if
      

  4.   

    借助一个 Visible = False 的 ListBox (设计时设置 Sorted = True) 排序:Dim total As IntegerList1.Clear        
    List1.AddItem Right("000" & Text1, 3)
    List1.AddItem Right("000" & Text2, 3)
    List1.AddItem Right("000" & Text3, 3)'一等:(1)平均分大于95
    '      (2)有两门等于100,另一门不小于80
    '二等:(1)平均大于90
    '      (2)有一门100,其它2门不少于75
    '三等: 各门不少于70Label4.Caption = ""
    total = Val(Text1) + Val(Text2) + Val(Text3)
    If total >= 285 Then
        Label4.Caption = "该学生获得一等奖学金!"
    ElseIf List1.List(0) >= "080" And List1.List(1) = "100" Then
        Label4.Caption = "该学生获得一等奖学金!"
    ElseIf total >= 270 Then
        Label4.Caption = "该学生获得二等奖学金!"
    ElseIf List1.List(0) >= "075" And List1.List(2) = "100" Then
        Label4.Caption = "该学生获得二等奖学金!"
    ElseIf total >= 210 Then
        Label4.Caption = "该学生获得三等奖学金!"
    End If
      

  5.   

    Label4.Caption = "该学生不能获得奖学金!"
    total = Val(Text1) + Val(Text2) + Val(Text3)
    If total >= 285 Then
        Label4.Caption = "该学生获得一等奖学金!"
    ElseIf List1.List(0) >= "080" And List1.List(1) = "100" Then
        Label4.Caption = "该学生获得一等奖学金!"
    ElseIf total >= 270 Then
        Label4.Caption = "该学生获得二等奖学金!"
    ElseIf List1.List(0) >= "075" And List1.List(2) = "100" Then
        Label4.Caption = "该学生获得二等奖学金!"
    ElseIf total >= 210 Then
        Label4.Caption = "该学生获得三等奖学金!"
    End If
      

  6.   

    Text1.Text + Text2.Text + Text3.Text=12+23+34=122334这样的成绩肯定是优秀的!
    改为 注其他数值转换你自己弄下
    Private Sub Command1_Click()
     If (CInt(Text1.Text) + CInt(Text2.Text) + CInt(Text3.Text)) \ 3 > 95 Or ((Text1.Text = 100 And Text2.Text = 100 And Text3.Text >= 80) Or (Text3.Text = 100 And Text2.Text = 100 And Text1.Text >= 80) Or (Text1.Text = 100 And Text3.Text = 100 And Text2.Text >= 80)) Then
      Label4.Caption = "该学生获得一等奖学金!"
       ElseIf (CInt(Text1.Text) + CInt(Text2.Text) + CInt(Text3.Text)) \ 3 > 90 Or ((Text1.Text = 100 And Text2.Text >= 75 And Text3.Text >= 75) Or (Text2.Text = 100 And Text1.Text >= 75 And Text3.Text >= 75) Or (Text3.Text = 100 And Text2.Text >= 75 And Text1.Text >= 75)) Then
          Label4.Caption = "该学生获得二等奖学金!"
           ElseIf Text1.Text >= 70 And Text2.Text >= 70 And Text3.Text >= 70 Then
             Label4.Caption = "该学生获得三等奖学金!"
              ElseIf Text1.Text < 70 And Text2.Text < 70 And Text3.Text < 70 Then Label4.Caption = "该学生不能获得奖学金!"
     End If
    End Sub
      

  7.   

    可以考虑把一些条件改用字符串方式判断
    比如 有两门等于100,另一门不小于80
    先把三门分数排序,从大到小依次赋给a,b,c三个字符串变量,然后对于上述条件的判断语句就是instr(1,a & b & c,"1001008") > 0
    这样应该可以省去几个判断,仅供参考楼主的代码里,首先除法应该是/而不是\;其次最后一个Else可以不写if条件限定;
    其它几楼里,有几位直接用三门成绩之和>280来取代有两门等于100,另一门不小于80的判断,是不正确的(如100+90+95)
      

  8.   

    楼主,你的问题大概出在第一个“If (Text1.Text + Text2.Text + Text3.Text) \ 3 > 95”判断里,因为text1.text里是字符,你这样直接+,其实是连接了字符串,比如我输入0,100,100它加起来是“100100”用100100/3当然比95大所以会出现输入100,100,0,或100,0,0,或50,50,50怎么都是一等奖学金!解决办法:
    ----------------------
    If (CInt(Trim(Text1.Text)) + CInt(Trim(Text2.Text)) + CInt(Trim(Text3.Text))) \ 3 > 95 or ....Then
    把第一个判断换一下,转一下数据类型!应该可以了!
    这段我已测试过了! 
      

  9.   

    错误:
    1 混淆了字符串和数值类型的区别。
    2 不小于要使用 >=
    3 算不上错误,但是啰嗦:
    ElseIf Text1.Text < 70 And Text2.Text < 70 And Text3.Text < 70 Then Label4.Caption = "该学生不能获得奖学金!"上面的条件已经穷尽了所有的奖金等级,此处不必再比较剩余的条件,Else 足矣。总的说来,算法设计不够精巧。如果有 10 门课,你的代码就没法读了。Private Sub Command1_Click()
    Dim t1 As Integer, t2 As Integer, t3 As Integer
    t1 = Val(Text1.Text)
    t2 = Val(Text2.Text)
    t3 = Val(Text3.Text) If (t1 + t2 + t3) \ 3 >= 95 Or ((t1 = 100 And t2 = 100 And t3 >= 80) Or (t3 = 100 And t2 = 100 And t1 >= 80) Or (t1 = 100 And t3 = 100 And t2 >= 80)) Then
      Label4.Caption = "该学生获得一等奖学金!"
       ElseIf (t1 + t2 + t3) \ 3 >= 90 Or ((t1 = 100 And t2 >= 75 And t3 >= 75) Or (t2 = 100 And t1 >= 75 And t3 >= 75) Or (t3 = 100 And t2 >= 75 And t1 >= 75)) Then
          Label4.Caption = "该学生获得二等奖学金!"
           ElseIf t1 >= 70 And t2 >= 70 And t3 >= 70 Then
             Label4.Caption = "该学生获得三等奖学金!"
              Else
              Label4.Caption = "该学生不能获得奖学金!"
     End If
    End Sub
      

  10.   

    a,b,c三门成绩:
    一等:(1)平均分大于95
          (2)有两门等于100,另一门不小于80
    if (a+b+c)/3>95 or _
       (a=100 and b=100 and c>=80) or _
       (a=100 and b>=80 and c=100) or _
       (a>=80 abd b=100 and c=100) then
          msgbox "一等奖"
    end if二等:(1)平均大于90
          (2)有一门100,其它2门不少于75
    if (a+b+c)/3>90 or _
       (a=100 and b>=75 and c>=75) or _
       (a>=75 and b=100 and c>=75) or _
       (a>=75 abd b>=75 and c=100) then
          msgbox "二等奖"
    end if三等:各门不少于70
    if a>70 and b>70 and c>70 then
        msgbox "三等奖"
    end if
      

  11.   

    如果要源程序请留个邮箱吧
    我用了控件数组
    Private Sub Command1_Click()
    Label5.Caption = ""
    Dim alert
    Dim count100 '记下100分的数量
    Dim not100(0 To 2) '记下<100分的成绩
    Dim score '总分
    Dim count70 '>=70 and <100 个数
    Dim count75 '>=75 and <100 个数
    Dim count80 '>=80 and <100 个数
    count100 = 0
    score = 0
    count70 = 0
    count75 = 0
    count80 = 0
    '验证输入数据的完整性
    For i = 0 To 2
    If Text1(i).Text = "" Then
    alert = alert + "请输入成绩" & i + 1 & vbCrLf
    End If
    Next
    If alert <> "" Then
    MsgBox alert
    Exit Sub
    End If
    Rem 判定情况
    For i = 0 To 2
    score = score + Text1(i).Text
    If Text1(i).Text = 100 Then
    count100 = count100 + 1
    not100(i) = 0 '100分的=0 区别于<100的
    Else
    not100(i) = Text1(i).Text '记下不是100分的成绩
    End If
    Next
    Rem 计数
    For i = 0 To 2
    If not100(i) >= 70 Then count70 = count70 + 1
    If not100(i) >= 75 Then count75 = count75 + 1
    If not100(i) >= 80 Then count80 = count80 + 1
    NextRem 开始评定奖学金
    If score >= 285 Then
    Label5.Caption = "该生获得一等奖学金!"ElseIf count100 >= 2 Then
          If count80 = 1 Then Label5.Caption = "该生获得一等奖学金!"
          
    ElseIf score >= 270 Then
    Label5.Caption = "该生获得二等奖学金!"ElseIf count100 = 1 Then
         If count75 = 2 Then Label5.Caption = "该生获得二等奖学金!"
         
    ElseIf count100 = 0 Then
         If count70 = 3 Then Label5.Caption = "该生获得三等奖学金!"
    End IfIf count70 < 3 Then Label5.Caption = "该生没有获得奖学金!"
    Rem 结束评定End SubPrivate Sub Command2_Click()
    For i = 0 To 2
    Text1(i).Text = ""
    Next
    End SubPrivate Sub Command3_Click()
    End
    End SubPrivate Sub Form_Load()
    Label4.Caption = "请输入成绩"
    End Sub运行通过了
    这是我第一次回帖奥
    大家鼓励一下吧!
    呵呵
      

  12.   

    Private Sub Command1_Click()
    Label5.Caption = ""
    Dim alert
    Dim count100 '记下100分的数量
    Dim not100(0 To 2) '记下<100分的成绩
    Dim score '总分
    Dim count70 '>=70 and <100 个数
    Dim count75 '>=75 and <100 个数
    Dim count80 '>=80 and <100 个数
    count100 = 0
    score = 0
    count70 = 0
    count75 = 0
    count80 = 0
    '验证输入数据的完整性
    For i = 0 To 2
    If Text1(i).Text = "" Then
    alert = alert + "请输入成绩" & i + 1 & vbCrLf
    End If
    Next
    If alert <> "" Then
    MsgBox alert
    Exit Sub
    End If
    Rem 判定情况
    For i = 0 To 2
    score = score + Text1(i).Text
    If Text1(i).Text = 100 Then
    count100 = count100 + 1
    not100(i) = 0 '100分的=0 区别于<100的
    Else
    not100(i) = Text1(i).Text '记下不是100分的成绩
    End If
    Next
    Rem 计数
    For i = 0 To 2
    If not100(i) >= 70 Then count70 = count70 + 1
    If not100(i) >= 75 Then count75 = count75 + 1
    If not100(i) >= 80 Then count80 = count80 + 1
    NextRem 开始评定奖学金
    If score >= 285 Then
    Label5.Caption = "该生获得一等奖学金!"ElseIf count100 >= 2 Then
          If count80 = 1 Then Label5.Caption = "该生获得一等奖学金!"
          
    ElseIf score >= 270 Then
    Label5.Caption = "该生获得二等奖学金!"ElseIf count100 = 1 Then
         If count75 = 2 Then Label5.Caption = "该生获得二等奖学金!"
         
    ElseIf count100 = 0 Then
         If count70 = 3 Then
           Label5.Caption = "该生获得三等奖学金!"
         Else
           Label5.Caption = "该生没有获得奖学金!"
         End If
    End If
    Rem 结束评定
    End SubPrivate Sub Command2_Click()
    For i = 0 To 2
    Text1(i).Text = ""
    Next
    End SubPrivate Sub Command3_Click()
    End
    End SubPrivate Sub Form_Load()
    Label4.Caption = "请输入成绩"
    End Sub