[ vidonk @ 13.05.2020. 18:03 ] @
Pokušavam da napravim igru memorije ali mi dava sledeću grešku Code: Run Time Error 361 Can't Load or unload this object I naznačen je kod Code: Load btnChoice(intNextNumber) A evo ga i cijeli kod Code: Option Explicit 'Variable to Check Playing Turn Private boolFirstChoice As Boolean 'Variable For Previous Index Chosen Private intFirstChoice As Integer 'Variable For Comparing Choices Private astrChoice(1 To 2) As String 'Variable For Keeping Pictures Visable Private aboolVisablePositions(1 To 8) As Boolean 'Note: Take Note Of The Properties On The Button And Image Boxes Private Sub Form_Load() 'Declare Dim intNextNumber As Integer 'Loop 'Load 8 Buttins And 8 Image Boxes For intNextNumber = 1 To 8 Load btnChoice(intNextNumber) Load imgPicture(intNextNumber) Next 'Move The Buttons And Image Boxes Call MoveControls(btnChoice) Call MoveControls(imgPicture) 'Make All Buttons Visable For intNextNumber = 1 To 8 btnChoice(intNextNumber).Visable = True Next 'Set The Randomize Generator Randomize 'Declare Temporary Dim aintRandomNumber(1 To 8) As Integer 'Get Random Numbers Call GetRandomNumbers(aintRandomNumber) 'Load The Pictures For intNextNumber = 1 To 8 Select Case aintRandomNumber(intNextNumber) Case 1, 2 'Santa imgPicture(intNextNumber).Picture = _ LoadPicture(App.Path & "\Santa.jpg") 'Set Tag imgPicture(intNextNumber).Tag = "Santa" Case 3, 4 'Gifts imgPicture(intNextNumber).Picture = _ LoadPicture(App.Path & "\Gifts.jpg") 'Set Tag imgPicture(intNextNumber).Tag = "Gifts" Case 5, 6 'Rudolph imgPicture(intNextNumber).Picture = _ LoadPicture(App.Path & "\Rudolph.jpg") 'Set Tag imgPicture(intNextNumber).Tag = "Rudoplph" Case 7, 8 'ChristmasTree imgPicture(intNextNumber).Picture = _ LoadPicture(App.Path & "\ChristmasTree.jpg") 'Set Tag imgPicture(intNextNumber).Tag = "ChristmasTree" End Select Next End Sub Private Sub MoveControls(objControl As Object) 'Move Controls objControl(1).Move 8, 8 objControl(2).Move 168, 8 objControl(3).Move 328, 8 objControl(4).Move 488, 8 objControl(5).Move 8, 160 objControl(6).Move 168, 160 objControl(7).Move 328, 160 objControl(8).Move 488, 160 End Sub Private Sub GetRandomNumbers(aintRandomNumber() As Integer) ' Pick A Random Nuber 1 Trough 8 aintRandomNumber(1) = CInt((Rnd * 7) + 1) 'Pick A Different Number Do Until aintRandomNumber(2) <> aintRandomNumber(1) _ And aintRandomNumber(2) <> 0 aintRandomNumber(2) = CInt((Rnd * 7) + 1) Loop 'Pick A Different Number Do Until aintRandomNumber(3) <> aintRandomNumber(2) _ And aintRandomNumber(3) <> aintRandomNumber(1) _ And aintRandomNumber(3) <> 0 aintRandomNumber(3) = CInt((Rnd * 7) + 1) 'Pick A Different Number Do Until aintRandomNumber(4) <> aintRandomNumber(3) _ And aintRandomNumber(4) <> aintRandomNumber(2) _ And aintRandomNumber(4) <> aintRandomNumber(1) _ And aintRandomNumber(4) <> 0 aintRandomNumber(4) = CInt((Rnd * 7) + 1) Loop 'Pick A Different Number Do Until aintRandomNumber(5) <> aintRandomNumber(4) _ And aintRandomNumber(5) <> aintRandomNumber(3) _ And aintRandomNumber(5) <> aintRandomNumber(2) _ And aintRandomNumber(5) <> aintRandomNumber(1) _ And aintRandomNumber(5) <> 0 aintRandomNumber(5) = CInt((Rnd * 7) + 1) Loop 'Pick A Different Number Do Until aintRandomNumber(6) <> aintRandomNumber(5) _ And aintRandomNumber(6) <> aintRandomNumber(4) _ And aintRandomNumber(6) <> aintRandomNumber(3) _ And aintRandomNumber(6) <> aintRandomNumber(2) _ And aintRandomNumber(6) <> aintRandomNumber(1) _ And aintRandomNumber(6) <> 0 aintRandomNumber(6) = CInt((Rnd * 7) + 1) Loop 'Pick A Different Number Do Until aintRandomNumber(7) <> aintRandomNumber(6) _ And aintRandomNumber(7) <> aintRandomNumber(5) _ And aintRandomNumber(7) <> aintRandomNumber(4) _ And aintRandomNumber(7) <> aintRandomNumber(3) _ And aintRandomNumber(7) <> aintRandomNumber(2) _ And aintRandomNumber(7) <> aintRandomNumber(1) _ And aintRandomNumber(7) <> 0 aintRandomNumber(7) = CInt((Rnd * 7) + 1) Loop 'Pick A Different Number Do Until aintRandomNumber(8) <> aintRandomNumber(7) _ And aintRandomNumber(8) <> aintRandomNumber(6) _ And aintRandomNumber(8) <> aintRandomNumber(5) _ And aintRandomNumber(8) <> aintRandomNumber(4) _ And aintRandomNumber(8) <> aintRandomNumber(3) _ And aintRandomNumber(8) <> aintRandomNumber(2) _ And aintRandomNumber(8) <> aintRandomNumber(1) _ And aintRandomNumber(8) <> 0 aintRandomNumber(8) = CInt((Rnd * 7) + 1) Loop End Sub Private Sub btnChoice_Click(Index As Integer) 'Check Turn If boolFirstChoice = False Then astrChoices(1) = imgPicture(Index).Tag intFirstChoice = Index boolFirstChoice = True Else astrChoices(2) = imgPicture(Index).Tag boolFirstChoice = False End If 'Visable Image Behind Button btnChoice(Index).Vasable = False imgPixture(Index).Visable = True 'Replay For Second Choice If boolFirstChoice = False Then 'MsgBox The Player If astrChoice(1) = astrChoice(2) Then aboolVisablePositions(intFirstChoice) = True aboolVisablePositions(Index) = True MsgBox "Matched" Else MsgBox "Not matched" End If 'Undo Choice Call UndoChoice End If 'If All Positions Are Visable Exit Program If AllPostionsVisable = True Then MsgBox "Game done" End End If End Sub Private Sub UndoChoice() 'Declare Dim intNextNumber As Integer 'Show All Buttons For intNextNumber = 1 To 8 If btnChoice(intNextNumber).Visable = False _ And aboolVisablePostions(intNextNumber) = False Then btnChoice(intNextNumber).Visable = True imgPixture(intNextNumber).Visable = False End If Next End Sub Private Function AllPositionsVisable() As Boolean 'Declare Dim intNextNumber As Integer 'Check All positions For intNextNumber = 1 To 8 If aboolVisablePosition(intNextNumber) = False Then AllPositionsVisable = False Exit Function End If Next 'Return AllPositionsVisable = True End Function 'Declare Dim intNextNumber As Integer Replay 'Check All positions For intNextNumber = 1 To 8 If aboolVisablePostions(intNextNumber) = False Then AllPositionsVisable = False Exit Function End If Next 'Return Function AllPositionsVisable = True End Function Private Sub Form_Unload(Cancel As Integer) 'Empty Form Memory Set frmMemoryGame = Nothing End Sub |