I am trying to make a memory game using labels and command buttons, and I have run across an issue in which when I try to set up a timer with a loop within a Sub function. My current code for this:

Private Sub Form_Load()
    tmrStart.Interval = "1"
End Sub

Private Sub tmrStart_Timer()
    Dim intTime As Integer
    intTime = 10

    If intTime = 0 Then
        lbl1.Visible = False
        lbl2.Visible = False
        lbl3.Visible = False
        lbl4.Visible = False
        lbl5.Visible = False
        lbl6.Visible = False
        lbl7.Visible = False
        lbl8.Visible = False
        lbl9.Visible = False
        lbl10.Visible = False
        lbl11.Visible = False
        lbl12.Visible = False
        lbl13.Visible = False
        lbl14.Visible = False
        lbl15.Visible = False
        lbl16.Visible = False
        lbl17.Visible = False
        lbl18.Visible = False
        lbl19.Visible = False
        lbl20.Visible = False
        intTime -1
    End If

    lblTime = "You have " & intTime & "to memorize!"
End Sub

Howver, when I run this code, it gives me an error which reads "Error: expected Sub, Function, or Property." Thinking logically, I changed the Sub to both a Function and a Property, to no avail.

This is also in VB5

Your mistake is on line No 33.

intTime -1

This produces your error.

it should be

intTime = intTime -1

I have non idea why I never tried that. Thank you for pointing out my error!

This question has already been answered. Start a new discussion instead.