TAILIEUCHUNG - Access 2007 VBA Programmer’s Reference phần 2

Ngoài việc hiển thị giá trị của biến, bạn cũng có thể thực thi lệnh VBA trong cửa sổ ngay lập tức. Chỉ cần loại bỏ? nhân vật và toàn bộ các loại lệnh, và sau đó nhấn Enter. Typing msgbox ("Tall hoặc Grande?") Và nhấn Enter sẽ hiển thị các tin nhắn được hiển thị trong Hình 4-5. | Chapter 4 Using the VBA Editor In addition to displaying the value of variables you can also execute VBA commands in the Immediate window. Just eliminate the character and type the entire command and then press Enter. Typing msg-box Tall or Grande and pressing Enter displays the message shown in Figure 4-5. Figure 4-5 You can even perform calculations in the Immediate window such as intTotalEmployees intTempEmployees intFullTimeEmployees. The Immediate window is also a powerful debugging tool for your applications. For more information about the Immediate window see Chapter 8. Using the Immediate window along with other aspects of the VBA Editor detailed in this chapter such as breakpoints and stepping through code is the most generally accepted method of debugging your code. However there are other options. One method that is often used by beginning developers is to place message box code throughout the code to test the values of selected variables or calculations. Although there is nothing technically wrong with this method it can be messy and cumbersome. After all when you re done debugging the code you still need to comment out or remove all of the message box calls. That can be a lot of unnecessary work. The Statement As you already know the character is short for and you ve seen how easy it is to use both commands directly in the Immediate window. That s not the only place you can use statements The following code illustrates how can be used within a module so you can imagine how it can be helpful for testing and debugging. Sub FunWithStringsAndNumbers Dim strBikes As String Dim strCost As String Dim strCustomerName As String Dim intBikes As Integer Dim curCost As Currency strBikes 5 strCost 100 strCustomerName The W Hotel New York City intBikes 5 curCost 100 strBikes strCost intBikes curCost strCustomerName End Sub 73 Chapter 4 Using the VBA Editor This code produces the .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.