http://picta55.blogspot.com
What is Visual Basic?
Visual Basic is a tool that allows us to develop Windows (Graphic User Interface - GUI) applications. The applications have a familiar appearance to the user.
What is Visual Basic?
วิชวลเบสิกคืออะไร
Visual Basic is a tool that allows us to develop Windows (Graphic User Interface - GUI) applications. The applications have a familiar appearance to the user.
Visual Basic is event-driven, meaning code remains idle until it is called upon to respond to some event (e.g. mouse clicking, button pressing, menu selection, ...). Nothing happens until an event is detected. Once an event is detected, the code corresponding to that event (event procedure) is executed.
How to program with Visual Basic?
Steps in Developing Application
ขั้นตอนการพัฒนาแอ็ปปลิเคชัน
ขั้นตอนการพัฒนาแอ็ปปลิเคชัน
There are three primary steps involved in building a Visual Basic application:
1. Draw the user interface
2. Assign properties to controls
3. Attach code to controls
Stop Watch Application
1 At the "Start-up Menu" of our Windows Desktop, let's find where "Microsoft Visual Studio 6.0" is, and click on it. Then we can see some shortcuts to the applications of the software suite, and "Microsoft Visual Basic6.0" is one of them and it is also our "target software" right now, let's select it.
At the "Start-up Menu of Windows", Find where the "Microsoft Visual Basic 6.0" is. |
Select the "Standard EXE" icon |
3 Before we go on, let's consider the components of the toolbar of Visual Basic 6.0. Properties window, Run and Save project are what we have to focus on now.
Design View of Visual Basic 6.0 |
4 Controls are the genius tools that can be attached by any codes that can control any events such as clicking mouse or pressing key. Now the "Command Button" and the "Label" are the controls that we are going to use.
Controls of Visual Basic 6.0 |
Form and Controls are variety kinds of object of Visual Basic that have their own properties. |
- Using the "Command Button" control to draw the three sequence command buttons, Command1,Command2 and Command3.
- Using the "Label" control to draw the six sequence labels, Label1,
Label2, Label3, Label4, Label5 and Label6
Form1 would have three command buttons and six labels now. |
Form1 Properties Configurations |
8 Click on "Command1", yes we are about to specify the properties of this object. Rename it with "cmdStart" (cmd is a prefix which comes from "command button") and also refill its caption with "&Start Timing" (& is a prefix of the key letter that a user can press on this key together with the "alt" key instead of click on this command button).
Change the properties of the command button : name and caption ให้นักเรียนเปลี่ยนชื่อ และแค็ปชันของปุ่มคำสั่ง |
9 Do it the same way as the previous step.
Change the properties of the command button : name and caption |
10 Do it the same way as the previous step.
Change the properties of the command button : name and caption |
11 Change only the captions of Label1, Label2 and Label3 according to the following picture.
Change the properties of the three labels : captions |
12 Change the properties of the other last three labels, "Label4", "Label5" and "Label6" by renaming them to "lblStart", "lblEnd" and "lblElapsed" and erase their captions until they are blank.
Change the properties of Label4, Label5 and Label6 according to the picture. |
Click on the "View" command at the menu bar, then select "Code" subcommand |
1st Line is about the General Declaration 2nd Line is the Declaration of variable "StartTime" 3rd Line is the Declaration of variable "EndTime" 4th Line is the Declaration of variable "ElapsedTime" |
What is about this source code? It begins with assigning the recent time value (Now) to the variable "StartTime". Then the method "Caption" stipulates that the label "lblStart" can show up data from the variable "startTime" with the "hh:mm:ss:" format.
Attach code to the command button "cmdStart" |
Attach code to the command button "cmdEnd" |
17 This is the end of application with the only amazing word "End"
Attach code to the command button "cmdExit" |
Our Graphic User Interface Application : "Stop Watch" |
ไม่มีความคิดเห็น:
แสดงความคิดเห็น