Visual Basic/VB6 problem


Hello, when I try and run this code the error message 'Compile Error: Sub or Function not defined' is shown.. With ' picNumber(GridPos) = I' High lighted. Im an a beginner using Visual Basic 6, and I am unsure of how to fix this what is wrong with the code to make it run. Any help would be aprreciated. Thanks.
Private Sub Form_Load()
Option Explicit
Dim picNumber(1 To 16) As Integer, Tries As Integer, Pairs As Integer
End Sub
Private Sub cmdExit_Click()
End Sub

Private Sub cmdNew_Click()
   Static Occupied(1 To 16) As Boolean
   Dim I As Integer, GridPos As Integer, Row As Integer, Column As Integer
   For I = 1 To 16
       Occupied(I) = False
   Next I
   For I = 1 To 16
       picCover(I).Visible = True
         Row = Int(Rnd * 4) + 1
         Column = Int(Rnd * 4) + 1
         GridPos = (Row - 1) * 4 + Column
       Loop While Occupied(GridPos)
       Occupied(GridPos) = True
       picNumber(GridPos) = I
       picIcon(I).Move = 480 + (Column - 1) * 1095 + 480 + (Row - 1) * 1095
   Next I
   Tries = 0
   Pairs = 0
   lblTries.Caption = 0
End Sub

Private Sub WasteTime()
   Dim start As Date
   start = Time
   Loop Until Second(Time - start) > 1
End Sub

Private Sub picCover_Click(Index As Integer)
   Static FirstCard As Integer, FirstCover As Integer
   Static SecondCard As Integer, SecondCover As Integer
   picCover(Index).Visible = False
   Tries = Tries + 1
   If Tries Mod 2 = 1 Then
   lblTries.Caption = Tries \ 2
   SecondCard = PicNo(Index)
   SecondCover = Index
   If (FirstCardMod8) = (SecondCard Mod 8) Then
       Pairs = Pairs + 1
       If Pairs = 8 Then
         MsgBox "Congratulations you've done it!", 48, "Puzzle Solved"
       End If
       picCover(FirstCover).Visible = True
       picCover(SecondCover).Visible = True
   End If
End If
End Sub

Private Sub picIcon_Click(Index As Integer)
End Sub

without looking at your code in full, the first error is to call cmdNew click. also for a beginner you have used too much, static variable, used a date variable  to equate with time variable. called functions etc declaring too many variables.

try running nothing with formLoad and if the error persists send me a zipped copy of your code to me along with what you want to achieve.

Visual Basic

All Answers

Answers by Expert:

Ask Experts




visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel.(VB6) basic questions in vb 2008. Optional: 1)a large number of people want me to do work which takes some time and effort. can do projects in vb 2008. Pl.note that i would like to be paid for such work. 2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time. 3) if you are pleased with my reply you could consider a good amount. 4) you can visit my website


programming since the past 15 years. have completed a large number of projects in Industrial applications, finance,accounts, correspondence. excel macros etc

engineering, management degrees.

Past/Present Clients
project work for a Norway company,USA company and a Canadian company completed. Freelance Project work and Teaching. helping programmers with their work
teaching vb

©2017 All rights reserved.