?
Solved

Does my program has to consist of just one file?

Posted on 2004-04-11
4
Medium Priority
?
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
appari earned 240 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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