We have created yet another chapter for our Excel VBA Tutorial. This chapter shows you how to create arrays in Excel VBA.
When we work with a single item, we only need to use one variable. However, if we have a list of items which are of similar type to deal with, we need to declare an array of variables instead of using a variable for each item. For example, if we need to enter one hundred names, instead of declaring one hundred different variables, we need to declare only one array. By definition, an array is a group of variables with the same data type and name. We differentiate each item in the array by using subscript, the index value of each item, for example name (1), name (2), name (3) .......etc.
Click on the link below to learn more.
http://www.vbtutor.net/VBA/vba_chp21.htm
This is a blog that discusses anything related to Visual Basic and provides updates for VISUAL BASIC TUTORIAL website. Your comments and suggestions are welcome here. Thank you.
Monday, April 19, 2010
Monday, April 12, 2010
Server Problem- My apology
Dear Vbtutor Users
Our server was not functioning properly due to technical glitch committed by our hosting provider. Most of the links to the lessons cannot be accessed at the moment, please accept our sincere apology. We are confident that the issue will be resolved in a couple of hours, so please be patient and check back again later.
If you still have problem logging to our lessons tomorrow, please leave your message here.
Your feedback is important for us, thank you.
The Vbtutor Support Team
Our server was not functioning properly due to technical glitch committed by our hosting provider. Most of the links to the lessons cannot be accessed at the moment, please accept our sincere apology. We are confident that the issue will be resolved in a couple of hours, so please be patient and check back again later.
If you still have problem logging to our lessons tomorrow, please leave your message here.
Your feedback is important for us, thank you.
The Vbtutor Support Team
Tuesday, March 23, 2010
Search for text files in your drives and display them
Recently I received an email from a reader who ask me a VB question as follows:
' - I have a folder and file name with *.txt in C: -> C:\Test
- I want to create a vb program to search all *.txt extension file
- If found then just desplay it to textbox.
How can we write this code? "
' - I have a folder and file name with *.txt in C: -> C:\Test
- I want to create a vb program to search all *.txt extension file
- If found then just desplay it to textbox.
How can we write this code? "
Well, I have one sample program that might fit this need. This program let you choose your drives and folders and displays all the text files from the chosen folder in a list box. You need to place a combo box, a DriveListBox, a DirListbox and a Listbox into your form. The code is as follows:
Private Sub Form_Load()
Left = (Screen.Width - Width) \ 2
Top = (Screen.Height - Height) \ 2
Combo1.Text = "All Text Files"
Combo1.AddItem "All Text Files"
Combo1.AddItem "All Files"
End Sub
Private Sub Combo1_Change()
If ListIndex = 0 Then
File1.Pattern = ("*.txt")
Else
Fiel1.Pattern = ("*.*")
End If
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
If Combo1.ListIndex = 0 Then
File1.Pattern = ("*.txt")
Else
File1.Pattern = ("*.*")
End If
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
If Combo1.ListIndex = 0 Then
File1.Pattern = ("*.txt")
Else
File1.Pattern = ("*.*")
End If
If Right(File1.Path, 1) <> "\" Then
filenam = File1.Path + "\" + File1.FileName
Else
filenam = File1.Path + File1.FileName
End If
Text1.Text = filenam
End Sub
Monday, January 4, 2010
New Lesson! Lesson 40-Creating Reports in VB6
You have learned how to build a database in Visual Basic 6 in previous lessons, however you have not learned how to display the saved data in a report. Reports are important and useful in many respects because they provide useful and meaningful information concerning a set of data. In this new lesson, we will show you how to create a report in Visual Basic 6.
Check out this new lesson at
Friday, November 20, 2009
Visual Basic- A personal experience Part 2
That only computer immediately became the sweetheart of everybody, and everyone can't wait to have a hand on it! And it could run BASIC!
There was no hard disk, you need a boot diskette to start it, then you insert a 5 and a half inch floppy disk that contain the BASIC program to start the BASIC DOS-based IDE. I can't remember what version of BASIC was it, could be GWBASIC, a dialect of BASIC developed by Microsoft from BASICA, originally for Compaq.
There was no hard disk, you need a boot diskette to start it, then you insert a 5 and a half inch floppy disk that contain the BASIC program to start the BASIC DOS-based IDE. I can't remember what version of BASIC was it, could be GWBASIC, a dialect of BASIC developed by Microsoft from BASICA, originally for Compaq.
Tuesday, November 10, 2009
Visual Basic- A personal experience
Do you know that computer software have been around since world war II? However, before 1975, most of the software were free, and one of the earliest computer language was BASIC. Those were the days without any PC, you have to type your programs on the punch cards and then feed them to the main frames and pick up the outputs the next day, how tedious and slow was it!
I was one of the hobbyists of BASIC back then, Bill Gates was one too! Programming back then was simple , the program is sequential and you need to type in the line numbers . However, the program can become very messy if you need to program something more complex, the line number can run to a couple of thousands, which means you have to punch a few thousand cards!
A BASIC program typically looks like this
10 Let X=100
20 Let Y =200
30 Z=X+Y
40 Print Z
One good thing about programming those days was that we get a lot of freebies! However, since Gates and his partner Paul Allen started commercializing BASIC, we no longer enjoy such benefits. But this is a good development because we learn to respect intellectual properties, and this will encourage creativity and innovations. True enough, with the advent of personal computers and commercialization of software, we get faster computers and more efficient software! We no longer have to use the punch cards and we can get the output of a program instantly, how nice!
That' enough for today, lets go programming!
Monday, October 26, 2009
Visual Basic for Business
Visual basic is a perfect programming language for building customized business applications. For example, you can design a payroll system, an inventory system, an order entry application, accounting software , financial calculator and more. All these applications involve the use of databases and Visual Basic is good at linking databases.
We are in the process of designing some business applications in VB . As soon as they are ready we will add them in our tutorial.
Happy programming.
Subscribe to:
Posts (Atom)