• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Does my program has to consist of just one file?

I have written a fairly long program (more than 3000 lines of code) and the code is located in one form(?!) is it possible to write functions and subs in another file, and then call those from the first form.
The reason is that it would be nice to divide the code to get a better overview, and dont have to have finished functions at same place as unfinished functions?
0
n96radsb
Asked:
n96radsb
  • 2
  • 2
1 Solution
 
appariCommented:
you can add bas modules then write public functions or subs and call them from other forms or modules.

to insert new a module in your project in project explorer window right click menu select add->module.
0
 
n96radsbAuthor Commented:
Okay, that worked, so I moved a sub to a new module. but now I cant write to text fields from the sub in the new module. it just says sub or function not defined when I try write in a text field. what shall I do?
0
 
appariCommented:
prefix text field name with form name, something like this

mainForm.txtName.text= "Name "

mainForm-> nbame of the form
txtname->name of the field
0
 
n96radsbAuthor Commented:
it worked excellent!
thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now