I got a college project for VBA and cant seem to get this code to work,help me pls

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PALETRON
    New Member
    • Jan 2010
    • 1

    #1

    I got a college project for VBA and cant seem to get this code to work,help me pls

    Dim Score As Byte
    Dim Teller As Byte
    Sub CommandButton1_ Click()
    If Teller < 3 Then
    If Me.CheckBox1.Va lue = False Then
    Me.CommandButto n6.Caption = (Int(Rnd * 6) + 1)
    Me.CommandButto n5.Caption = (Int(Rnd * 6) + 1)
    Me.CommandButto n4.Caption = (Int(Rnd * 6) + 1)
    Me.CommandButto n3.Caption = (Int(Rnd * 6) + 1)
    Me.CommandButto n2.Caption = (Int(Rnd * 6) + 1)
    End If
    Teller = Teller + 1
    End If

    End Sub
    Sub CheckBox1_Click ()
    If Me.CheckBox1.Va lue = False Then
    Me.CommandButto n6.Caption = (Int(Rnd * 6) + 1)
    Me.CommandButto n5.Caption = (Int(Rnd * 6) + 1)
    Me.CommandButto n4.Caption = (Int(Rnd * 6) + 1)
    Me.CommandButto n3.Caption = (Int(Rnd * 6) + 1)
    Me.CommandButto n2.Caption = (Int(Rnd * 6) + 1)
    End If
    End Sub

    Sub Label1_Click()

    If CommandButton6 = 1 Then Score = Score + 1
    If CommandButton5 = 1 Then Score = Score + 1
    If CommandButton4 = 1 Then Score = Score + 1
    If CommandButton3 = 1 Then Score = Score + 1
    If CommandButton2 = 1 Then Score = Score + 1
    Me.TextBox1.Val ue = Score
    Teller = 0
    End Sub
  • smartchap
    New Member
    • Dec 2007
    • 236

    #2
    Dear Paletron, u'r welcome to this forum.
    First of all a variable dimensioned as Byte can't be used as an Integer. So declare Teller as
    Dim Teller As Integer

    Now tell me exactly what is ur project & what problem u r facing so that we can help u more.

    Comment

    • smartchap
      New Member
      • Dec 2007
      • 236

      #3
      One more thing declare Score also as Integer:
      Dim Score As Integer

      I think it will make ur program work.

      Comment

      Working...