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?
n96radsbAsked:
Who is Participating?
 
appariConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.