Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I use .bas files?

Posted on 1998-12-29
3
Medium Priority
?
806 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 40 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

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

604 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