前面有Dim imput as integer 
Private Sub Command1_Click()
   If imput > 3000 Then Text2.Text = Str(6.8)
   ElseIf imput > 2000 And imput <= 3000 Then Text2.Text = Str(7)
   ElseIf imput > 1000 And imput <= 2000 Then Text2.Text = Str(8)
   ElseIf imput > 500 And imput <= 1000 Then Text2.Text = Str(9)
   Else: Text2.Text = "无折扣."
   End If
End Sub
这里怎么总是报错:“编译错误:Else 没有 If” ,为什么会这样?我把上面的ElseIf 改为 Else If 也不行!??

解决方案 »

  1.   

    If imput > 3000 Then Text2.Text = Str(6.8) 
    这句错了,要分行
      

  2.   

    Else: Text2.Text = "无折扣." 改为
    Else
     Text2.Text = "无折扣." 
      

  3.   

    Private Sub Command1_Click() 
      If imput > 3000 Then 
          Text2.Text = Str(6.8) 
      ElseIf imput > 2000 And imput <= 3000 Then 
           Text2.Text = Str(7) 
      ElseIf imput > 1000 And imput <= 2000 Then 
           Text2.Text = Str(8) 
      ElseIf imput > 500 And imput <= 1000 Then 
          Text2.Text = Str(9) 
      Else: Text2.Text = "无折扣." 
      End If 
    End Sub
      

  4.   

    对   If imput > 3000 Then Text2.Text = Str(6.8)   改成   
    If imput > 3000 Then 
      Text2.Text = Str(6.8)
      

  5.   

    用SELECT CASE
    不要用这么多ELSEIF