if-and-then problem (i know -noob question- )

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alcapoontje
    New Member
    • Jul 2006
    • 10

    if-and-then problem (i know -noob question- )

    Private Sub cmd3_Click()
    form3.Show
    form2.Hide
    End Sub
    If cmd3_Click And box3.Text = box4.Text Then
    score2.Caption = Val(score2) + 1
    If cmd_click And box3.Text <> box4.Text Then
    score1.Caption = Val(score1) + 1
    End Sub

    when i type this, the computer gives an error.
    I already tried hundres of things but it doesn't work.
    can someone help me pls

    -peter-
  • alcapoontje
    New Member
    • Jul 2006
    • 10

    #2
    before i forget,
    this is made in viusal basic excell.

    -peter-

    Comment

    • sashi
      Recognized Expert Top Contributor
      • Jun 2006
      • 1749

      #3
      Hi there,

      i have made some minor modification to your code n it should work fine now.. every if statement must end with endif.. always remember this when dealing with vb.. good luck my fren.. :)

      Code:
        If <some condition> Then
          ..do something..
        EndIf
      Code:
        If <some condition> Then
          ..do something..
        ElseIf <another condition> Then
          ..do something else.. 
        EndIf
      Code:
      Private Sub cmd3_Click()
         form3.Show
         form2.Hide
      End Sub
      
        If cmd3_Click And box3.Text = box4.Text Then
          score2.Caption = Val(score2) + 1
        ElseIf cmd_click And box3.Text <> box4.Text Then
          score1.Caption = Val(score1) + 1
        EndIf
      
      End Sub

      Comment

      • alcapoontje
        New Member
        • Jul 2006
        • 10

        #4
        thank you very much

        Comment

        • alcapoontje
          New Member
          • Jul 2006
          • 10

          #5
          but when ido this i get an error that there's a function or variable is expected and the cmd3_click on rule 6 is marked in yellow.


          -peter-

          Comment

          • alcapoontje
            New Member
            • Jul 2006
            • 10

            #6
            never mind, i found it myself

            Comment

            • BSOB
              New Member
              • Jul 2006
              • 77

              #7
              i know you said you found it yourself. but im not sure if you meant you "found" it or "fixed" it. cmd3_click does not evalute to true or false. if you are trying to find if the button has been clicked make a boolean variable (in general declarations) and have the button click event sub set the variable to true. then have your if statement look at the variable.

              Comment

              Working...