Solved

How do I use .bas files?

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

726 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