Brandon
Brandon

Reputation: 103

VB6 expected end of statement

I can't figure out what I'm doing wrong. I keep getting the error "Expected: end of statement" under the 'Display output. comment.

Option Explicit

Private Sub cmdOkay_click()
    'Declare counter variable (p)
        Dim p As Integer
        p = 8

    'Declare variable to hold calculated minutes
        Dim minutes As Integer

    'Display title of chart in listbox
        MyListBox.AddItem “Cooking Chart”

    'For each pound (from 8 to 23), calculate and display minutes

        For p = 8 To 23
           'Calculate minutes.pounds * 17
            minutes = p * 17

    'Display output.
        MyListBox.AddItem p & “ lbs, “ & minutes & “ minutes.” ERROR
    Next p

End Sub

Private Sub cmdExit_Click()
    End
End Sub

Upvotes: 0

Views: 993

Answers (1)

Fred
Fred

Reputation: 5808

Your code didn't run because of the double quotes. I changed them and it ran without error

Copy and paste this code:

    'Declare counter variable (p)
    Dim p As Integer
    p = 8

'Declare variable to hold calculated minutes
    Dim minutes As Integer

'Display title of chart in listbox
    MyListBox.AddItem "Cooking Chart"


'For each pound (from 8 to 23), calculate and display minutes

    For p = 8 To 23
       'Calculate minutes.pounds * 17
        minutes = p * 17

       'Display output.
        MyListBox.AddItem p & " lbs, " & minutes & " minutes."
    Next p

Upvotes: 3

Related Questions