|
-
February 10th, 2000, 10:03 AM
#1
Modules
i dont really fully understand what a module is for. can you please help me understand¿
-
February 10th, 2000, 10:12 AM
#2
Re: Modules
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
-
February 10th, 2000, 10:26 AM
#3
-
February 10th, 2000, 03:49 PM
#4
Re: Modules
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|