# Visual Basic > Visual Basic 6 and Earlier >  [RESOLVED] Wsa module realy necessary

## el84

I have developed an app that works* fine*, examining the capacity etc of drives.
I have used a module as follows



```
Option Explicit
Global SectorsPerCluster As Long
Global BytesPerSector As Long
Global FreeClusters As Long
Global TotalClusters As Long
Declare Function GetDiskFreeSpace Lib "kernel32" Alias _
    "GetDiskFreeSpaceA" (ByVal lpRotPathName As String, _
    lpSectorsPerCluster As Long, lpBytesPerSector As Long, _
    lpFreeClusters As Long, lpTotalClusters _
    As Long) As Long
```

And in the (one) form ... I have



```
slDL = GetDiskFreeSpace(Drive, SectorsPerCluster, BytesPerSector, FreeClusters, TotalClusters)
```

..after which I analyse and display the results...

My question is "Could I have simply placed the module code in my form (before Form load) and not used a module at all, maybe changing the Globals to Dim?" Please explain the reason for your answer!

Ps: Apologies for atrocious spelling in thread title!

----------


## el84

I'm guessing here (or maybe reviving old memories) but I am assuming that the advantage of a module is the Functions etc are available to many forms in the same project. As I only have one form in this, maybe no need? Am I getting warm?

----------


## dilettante

I don't see anything special there, so I'd think the reason a static module was used in order to stick the stuff _somewhere_ for multiple uses from elsewhere.  A class module could also work, but doesn't add any real value for a simple call like this.

I suppose another benefit of a separate module might be to make it clearer for reuse, since the module has everything required with nothing extra in it. More of a cookbook than a module for actual use.


In a small program you probably don't need to reduce clutter in the one form module by moving the code to some other module instead.  So for something like this just go ahead a drop it inline within your Form when that makes sense.

In a larger program it might make sense to drop it into a utility module along with other random flat calls and definitions for enums, structs, etc.

----------


## el84

Thanks! So put it at the start of my one form (BTW it is currently in a bas module). I do apologise to all for this simple query!

----------


## el84

I've just noticed a typo in the Function. 'lpRotPathName' obviously should be 'lpRootPathName'. Funny thing, both work! Can someone explain that?

----------


## VanGoghGaming

That's a parameter name, you can name it anything you want, even "sausage".

----------


## el84

Transferred module code to the start of the form. Error message. For once 'Help' was  heLp! Before 'Declare Function' with 'Private' All ok now. Was that what was needed?

----------


## el84

I wondered why I got so few responses to my question.
I think the clue is my words in the opening post: 'Please explain the reason for your answer!'. 
That sounds awfully like a test or exam, and possible posters probably thought I was another pesky student trying to crib my homework! 
I can assure all that I am at the other end of my life. Trying now and then to pick up on earlier quite active use of Vb6.
My background goes back to DOS, BASIC and 'Electric Pencil' (1979-80!)

----------

