TAILIEUCHUNG - Beginning Visual Basic 2005 phần 4

Bây giờ là lúc để sử dụng một số các đoạn mã dựng sẵn đi kèm với Visual Studio 2005. Nhấp chuột phải vào trong không gian trống giữa Nếu Cuối Nếu báo cáo và chọn Thủ thuật Insert từ menu ngữ cảnh. Trong trình đơn thả xuống xuất hiện,cũng như kiểm soát phức tạp khác như kiểm soát động, ví dụ, có khả năng để chơi | Chapter 7 Show the Open dialog and if the user clicks the Open button load the file If Then End If End Sub 8. Now it s time to use some of the prebuilt code snippets that come with Visual Studio 2005. Right click in the blank space between the If and End If statements and choose Insert Snippet from the context menu. In the drop-down menu that appears double-click File System - Processing Drives Folders and Files and then scroll down the new list and double-click Read Text from a File. Your code should now look like this and you ll notice that the filename is highlighted indicating that this code needs to be changed If Then Dim allText As String Try allText Catch fileException As Exception Throw fileException End Try End If 9. Modify the code in the Try block as shown here Try Save the file name strFileName Read the contents of the file allText strFileName Display the file contents in the TextBox allText Catch fileException As Exception 10. Now run your project and once your form is displayed click the Open button to have the Open File dialog box displayed. Notice the custom caption in the title bar of the dialog box you specified this in your code. If you click the Files of type combo box you will see two filters. Click the second filter to see all of the files in the current directory. 11. Now locate a text file on your computer and select it. Then click the Open button to have the file opened and the contents of that file placed in the text box on the form as shown in Figure 7-8. 12. For the final test close your application and then start it again. Click the Open button on the form and notice that the Open File dialog box has opened in the last directory where you selected the last file from. How It Works Before displaying the

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.