Solved

How do I use .bas files?

Posted on 1998-12-29
3
728 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

708 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