Author: Dan Honeycutt
Date: 09:41:55 04/07/04
Go up one level in this thread
On April 07, 2004 at 11:35:25, S J J wrote: >On April 07, 2004 at 11:06:28, Dan Honeycutt wrote: > >>On April 07, 2004 at 10:50:17, S J J wrote: >> >>> I've been writing a program using Visual Basic. The pieces are >>>being stored in an Array. When the pieces are moved within the >>>subroutine which the Array was created in, all the pieces move >>>correctly. However, when another subroutine is asked to work >>>on the Array, I get the message "Compile error: Sub or Function not defined". >>> Are there any ideas as to what is causing the problem or what can be done >>>to fix it? >>> >>>Thanks, >>>Steve >> >>Make the array global or pass a reference to the array to the subroutine. If >>that's not clear let me know and I'll post skeleton code for you. >> >>Dan H. > > >Thanks Dan. Yes, I'd appreciate any skeleton code you could post. >Regards, >Steve Steve: In the following Sub1 calls Sub1a to place a white rook on square 1 on the global board. Sub2 calls Sub2a to place a white rook on square 1 on a local (to Sub2) board. Sub2a could also take the global board as an arguement. I see in your post to Andrew what you are doing will operate like Sub2 and Sub2a. Dan H. Option Explicit Public Const white_rook = 5 Public global_board(64) As Integer Sub Sub1() Sub1a Debug.Print global_board(1) '5 End Sub Sub Sub1a() global_board(1) = white_rook End Sub Sub Sub2() Dim local_board(64) As Integer Sub2a local_board 'note just array name, no () Debug.Print local_board(1) '5 End Sub Sub Sub2a(any_board() As Integer) any_board(1) = white_rook End Sub
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.