Solved

Does my program has to consist of just one file?

Posted on 2004-04-11
4
146 Views
Last Modified: 2010-05-02
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
Comment
Question by:n96radsb
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
appari earned 80 total points
ID: 10803993
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
 

Author Comment

by:n96radsb
ID: 10804111
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
 
LVL 39

Expert Comment

by:appari
ID: 10804124
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
 

Author Comment

by:n96radsb
ID: 10804276
it worked excellent!
thanks.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now