Jump to content

visual basic 6.0 Help

CripDawg

i know this software is very old but i am having trouble with creating a memory game in 6.0 for a school assignment i get the following compile  errors 

 

Sub or function undefined (GREEN)

Expected end of statement (RED)

 

Option Explicit
    Dim PicNummber(1 To 16) As Integer, Tries As Integer, Pairs As Integer
 
Public Sub WasteTime()
    Dim Start As Date
    Start = Time
    Do
    Loop Until Second(Time - Start) > 1
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
    Randomize
    For I = 1 To 16
      Occupied(I) = False
    Next I
    For I = 1 To 16
      picCover(I).Visible = True
      Do
        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) * 720, 480 + (Row - 1) * 720
    Next I
    Tries = 0
    Pairs = 0
    lblTries.Caption = 0
End Sub
 
Private Sub Form_Load()
    cmdNew_Click
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
    DoEvents
    Tries = Tries + 1
    If Tries Mod 2 = 1 Then
      FirstCard = PicNumber(Index)
      FirstCover = Index
    Else
    lblTries.Caption = Tries / 2
    SecondCard = PicNo(Index)
    SecondCover = Index
    If (FirstCard Mod 8) = (SecondCard Mod 8) Then
    Pairs = Pairs + 1
    If Pairs = 8 Then
      MsgBox "Congratulations Faggot you win", 48, "Puzzle Solved"
    End If
    Else
    WasteTime
    picCover(FirstCover).Visible = True
    picCover(SecondCover).Visible = True
    End If
    End If
    
    
End Sub
 
Private Sub picIcon_Click(Index As Integer)
    Beep
End Sub
 

 

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

line 2, there are 2 m's in PicNumber, that is probably causing the compiler to think that it is undefined when called later.

As for the second error, I don't know VB so I can't help you

I remain,  

msevilgenius

Link to comment
Share on other sites

Link to post
Share on other sites

line 2, there are 2 m's in PicNumber, that is probably causing the compiler to think that it is undefined when called later.

As for the second error, I don't know VB so I can't help you

Thanks man that fixed it now ive got syntax error on the line highlighted RED 

Link to comment
Share on other sites

Link to post
Share on other sites

isn't .move a function?

 

you can't assign something with commas by doing a.x = y, z

 

do you mean to do this? -   a.x(y,z) ?

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

isn't .move a function?

 

you can't assign something with commas by doing a.x = y, z

 

do you mean to do this? -   a.x(y,z) ?

i don't know could you just show me the correct line of code please it would be much appreciated :)

Link to comment
Share on other sites

Link to post
Share on other sites

Could you show the rest of the code? I can't tell how you've defined certain functions.

 

 

I was on about the red one: picIcon(I).Move = 480 + (Column - 1) * 720, 480 + (Row - 1) * 720

try picIcon(I).Move(480 + (Column - 1) * 720, 480 + (Row - 1) * 720)

 

how have you defined Move?

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

Could you show the rest of the code? I can't tell how you've defined certain functions.

 

 

I was on about the red one: picIcon(I).Move = 480 + (Column - 1) * 720, 480 + (Row - 1) * 720

try picIcon(I).Move(480 + (Column - 1) * 720, 480 + (Row - 1) * 720)

 

how have you defined Move?

i have no idea i just copy the code from the textbook i am still getting a syntax error on the same line but its no longer highlighting the comma no it doing the entire line 

P.S that is all the code

Link to comment
Share on other sites

Link to post
Share on other sites

there should be more. 

for example, "picIcon" isn't defined anywhere in that code, so it must be somewhere else.

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

there should be more. 

for example, "picIcon" isn't defined anywhere in that code, so it must be somewhere else.

picIcon and picCover are the names of the 2 arrays i have created on the form does this help at all?

Link to comment
Share on other sites

Link to post
Share on other sites

picIcon and picCover are the names of the 2 arrays i have created on the form does this help at all?

arrays of what?

 

you're calling a method on an object in an array so i need to know what the object is :P

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

arrays of what?

 

you're calling a method on an object in an array so i need to know what the object is :P

a picture box

Link to comment
Share on other sites

Link to post
Share on other sites

a picture box

  the .Move method of a picture box takes 4 variables 

 

PictureBox.Move(int x, int y, int width, int height)

you're only giving it 2 so you get the error.

 

 

try using

picIcon.Left = 480 + (Column - 1) * 720

picIcon.Top =  480 + (Row - 1) * 720           

(is this the right way round for calculating your x position and y position? -- before you tried putting column (y),row (x) rather than the usual row (x) column (y) order.)

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

  the .Move method of a picture box takes 4 variables 

 

PictureBox.Move(int x, int y, int width, int height)

you're only giving it 2 so you get the error.

 

 

try using

picIcon.Left = 480 + (Column - 1) * 720

picIcon.Top =  480 + (Row - 1) * 720           

(is this the right way round for calculating your x position and y position? -- before you tried putting column (y),row (x) rather than the usual row (x) column (y) order.)

method not found .Left

Link to comment
Share on other sites

Link to post
Share on other sites

.Left isn't a method, it's a property. - don't use brackets.

 

take a look at this for everything you need regarding modifying picturebox objects

 

http://msdn.microsoft.com/en-us/library/zzt5x46b(v=vs.90).aspx

 

It seems that you need to have a read on the basic syntax of programming languages - classes/objects, methods/functions, properties, variables, constructors, assigning value. then you should realise what you're missing.

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×