Solved

How do I use .bas files?

Posted on 1998-12-29
3
740 Views
Last Modified: 2012-06-22
the question title is self explainatory. how do i use a .bas file after i dl it? how do i add it to the vb form? do i need to add code with the .bas files?
0
Comment
Question by:LearningVB
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
vbWhiz earned 10 total points
ID: 1453099
A .bas file is simply a vb module file. To include the .bas file in your project you can use several methods.

Method 1:
  Open the windows explorer and your VB project. Drag & Drop the .bas file into the project explorer in VB (the area on the right panel that looks like the tree-view part of the windows explorer)

Method 2:
  Open the VB project. Right-Click in the project explorer panel. On the pop-up menu select add/module. A new window will pop open with two tabs. Click the 'existing' tab. Navigate through your files and find the .bas file to use.

Method 3:
  Open the VB project. On the button-bar across the top click the down-arrow next to the second button on the left (the tooltip for the button says 'new form'). A menu should appear. Click the 'new module' menu selection. . A new window will pop open with two tabs. Click the 'existing' tab. Navigate through your files and find the .bas file to use.


I hope this helps you out!
0
 

Author Comment

by:LearningVB
ID: 1453100
Thanx. When I figure out how to do this I'm sure it'll work... I think?
0
 
LVL 3

Expert Comment

by:vbWhiz
ID: 1453101
A visual basic module (.bas) can contain:

Variable Declarations

Functions

Subs

Constant Declarations

If any of these are declared public they can be used in the rest of your application.

This is some code that could exist in a VB module:

OPTION EXPLICIT

Private MyInt As Integer

Public MyString As String

Private Const HelloText = "Hello"

Public Const GoodByeText = "Goodbye"

Private Sub sayhello()

msgbox hellotext

end sub

Public Sub sayGoodbye()

msgbox goodbytext

end sub

Private Function AddFive(Value AS Integer) As Integer

AddFive = Value + 5

End Function

Public Function AddTen(Value As Integer) As Integer

AddTen = AddFive(AddFive(Value))

End Function



To See this sample work add a new module using one of the methods I described earlier but this time select 'New Module' rather than finding an existing one.

Copy&Paste the sample code into the new module.

Add a new form to the project.

Try adding a button and using the 'AddTen' Function on the click event.(SAMPLE CODE: Msgbox AddTen(35))

Try using some of the other functions and subs.

Notice that all things that are Private cannot be used in the form. Notice that all things that are public may be used freely on the form.


I hope this helps you understand modules better. In typical application developement a module is where you put common subs or functions that the rest of the program can use on demand.

Many times companies have several common modules that contain subs & functions that they use on many projects. In that case each new project they work on they already have pre-written code that they can take advantage of in any subsequent projects.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

947 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

19 Experts available now in Live!

Get 1:1 Help Now