Click to See Complete Forum and Search --> : Modules


Starcraft
February 10th, 2000, 09:03 AM
i dont really fully understand what a module is for. can you please help me understand¿

February 10th, 2000, 09:12 AM
Basically Modules are for holding public subroutines/variables and constants in your project.
Anything that you declare as public in a module can be accessed by all forms in your project.
The same is true if you declare something as public at the form level but if you reference a public routine in a form then that form will get loaded into memory so putting them in modules is the best answer

Chris Eastwood
February 10th, 2000, 09:26 AM
Take a look at :

http://codeguru.developer.com/bbs/wt/showpost.pl?Board=vb&Number=10903&page=&view=&sb=


Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

AndyK
February 10th, 2000, 02:49 PM
I'll try to explain really simple.....module is just basically a lot of code putted into one call
for example you have 20 command buttons and each does the same thing, for example when pressing each command button this code is executed:

Form1.Text8.Text = GetFromIni("1", "X", App.Path + "\Settings.ini")
Form1.Text9.Text = GetFromIni("1", "Y", App.Path + "\Settings.ini")
Form1.Text10.Text = GetFromIni("1", "MIN", App.Path + "\Settings.ini")
Form1.Text11.Text = GetFromIni("1", "SEC", App.Path + "\Settings.ini")
Form1.Text12.Text = GetFromIni("1", "#", App.Path + "\Settings.ini")
'2======================
Form1.Text13.Text = GetFromIni("2", "X", App.Path + "\Settings.ini")
Form1.Text14.Text = GetFromIni("2", "Y", App.Path + "\Settings.ini")
Form1.Text15.Text = GetFromIni("2", "MIN", App.Path + "\Settings.ini")
Form1.Text16.Text = GetFromIni("2", "SEC", App.Path + "\Settings.ini")
Form1.Text17.Text = GetFromIni("2", "#", App.Path + "\Settings.ini")
'3======================
Form1.Text18.Text = GetFromIni("3", "X", App.Path + "\Settings.ini")
Form1.Text19.Text = GetFromIni("3", "Y", App.Path + "\Settings.ini")
Form1.Text20.Text = GetFromIni("3", "MIN", App.Path + "\Settings.ini")
Form1.Text21.Text = GetFromIni("3", "SEC", App.Path + "\Settings.ini")
Form1.Text22.Text = GetFromIni("3", "#", App.Path + "\Settings.ini")



(That was just an example from my program) so now when you press command3, or 4 or 5 you will have to type all those lines again, but if you use module, you could place all those lines into a module

public Sub SaveData ()
all those lines
End Sub



and from each command button call that public sub

private Sub Command1_Click()
Call SaveData
End Sub
private Sub Command2_Click()
Call SaveData
End Sub
etc.



now all you need is to place Call SaveData into command buttons instead of 15 or more lines of code that saves you a lot of coding time and it decreases size of the program