When you create your user control like
Partial Class MyModule
Inherits DotNetNuke.Entities.Modules.PortalModuleBase
The inherits tells your control that it is based on the PortalModuleBase class of DNN.
And as a result - when your module runs - all of the stuff that PortalModuleBase does is automatically including in your module - thats what Object based programming is all about.
This class has a whole boat load of stuff going on inside it - part of which is to expose a heap of properties of the DNN environment to the module.
PortalId and ModuleId are two of the most useful.
UserId and PortalSettings and properties like IsEditable are also wrapped up in the class.
I would suggest that you spend some time looking at the DNN source code and specially at PortalModuleBase and if you want to know a lot more.
Just to add a bit of confusion - there is also a UserModuleBase class used internally by DNN that exposes some other User related elements - Its worth have a look at its code in the source library as well - BUT I would not suggest you try using it as the basis for your own modules since it does do a couple of odd things relating to how the rego system works - which may end up screwing you up.
It can be found in the source code installer /Library/Components/Modules
>>>>>>>>>
As to what you do with ModuleId - well thats really up to you - and the module you are writing.
ModuleId is a unique idkey to the module when it is place on a site - such that if you put the same module on two pages or even two modules on the same page - each one will have its own module ID.
Westa