LearningVB
asked on
How do I use .bas files?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER