本帖最后由 bcrun 于 2012-01-12 18:01:08 编辑

解决方案 »

  1.   

    本帖最后由 bcrun 于 2012-01-12 18:03:14 编辑
      

  2.   

    if ... then ....
    '或者:
    if ... then 
       ...
    end if
      

  3.   

    If b = 0 Then Text3.Text = "N"
    改为
    If b = 0 Then 
        Text3.Text = "N"
      

  4.   

    本帖最后由 bcrun 于 2012-01-12 18:19:09 编辑
      

  5.   

    VB是这样解释原来的代码的:
    Private Sub 除_Click()
    a = CInt(Text1.Text)
    b = CInt(Text2.Text)
    If b = 0 Then
        Text3.Text = "N"
    End If
    Text2.SetFocus
    Exit Sub
    End If
    result = a / b
    Label2.Caption = "/"
    Text3.Text = result
    End Sub
    正确的应该是
    Private Sub 除_Click()
    a = CInt(Text1.Text)
    b = CInt(Text2.Text)
    If b = 0 Then
        Text3.Text = "N"
        Text2.SetFocus
        Exit Sub
    End If
    result = a / b
    Label2.Caption = "/"
    Text3.Text = result
    End Sub
    vb对于
    if <a> then <b>
        <c>
    end if
    这样的解释是
    if <a> then
        <b>
    end if
    <c>
    end if
    当然会多一个end if了
      

  6.   

    你的if语句是单行IF语句,因此end if 是多余的,改成块状的就好了
      

  7.   

    if 结构有单行和块结构
    分别是
    单行
    if 条件 then 结果1[else 结果2]
    块结构
    if 条件 then
      结果1
    [else
      结果2]
    end if