Can a Module be created with code?

Hello Everyone,

Modules can be created in Xojo by dragging-and-dropping a module control in the Xojo IDE. Can a module be created with code?

I tried this and received a syntax error:

Dim MyModule as new module

Not sure if this is possible, Just asking :slight_smile:

No. new is used to create instances of a class.

Modules as well as Classes must be defined AS your code…
The difference is you can create instances of a CLASS (with NEW as Eli stated)
but there is no such a thing as a “module control” or “module object”

A Module is a “page” that holds code that defines methods, functions and properties, of which any can be PUBLIC (available to the entire application) or PRIVATE (available only to code inside the module)

It is possible (although ill advised) to create ALL of your application code inside a single module.

Thanks Eli and Dave!

Dave, this is good additional information about Modules. Thank you!

Are you looking for something like XojoScript?
http://documentation.xojo.com/index.php/XojoScript

Hi David,

Thanks for the reply. I was trying to make a struct (structure) by code for a Declare. A struct-like assembly can be made with a module by dragging-and-dropping a control, and I was trying to see if I could make it with straight code.

Thanks for your help though!