There's something that I don't understand.

If you have a program that several users can access at the same time. Then how do I prevent users from changing the outcome of functions and procedures of users which are also using those functions at the same time?

Let's say that user 1 is in a directory which has 20 files. and user 1 starts a function which retrieves the directory listing. He calls the function RetrieveDir(user) where user is 1.

The function then retrieves the list and stores:
Dim x
User(user).file(x) = filename1 x=x+1)
User(user).file(x) = filename2 x=x+1)
etc. etc.

This would work fine, but what if user 2 calls the same function in a directory with ony 4 files
while the function is still working on User(1) file 5?

wouldn't user(2) then get files 5-20 from user(1) while there are only 4 files, and wouldn't user(1) never exit that function?

And doesn't the Dim X that user(2) triggers reset the value of X that user(1) was still using?

um... is it a little clear what my problem is?

How can I make a function so that everyone can access it no matter when and the outcome would be correct even if other users are in that same function at the same time?