tailieunhanh - Beginning microsoft Visual Basic 2010 phần 5

Quay trở lại với thiết kế hình thức trong các dự án Windows Forms Hộp thoại. Kéo một điều khiển Button từ hộp công cụ và thả nó bên dưới nút Open và thiết lập các thuộc tính của nó như sau:Thiết lập Tên để btnSave. Thiết lập Neo lên trên, phải. Ấn định địa điểm 349, 43. Thiết lập Text to Save. | 254 I CHAPTER 8 DISPLAYING DIALOG BOXES 1. Return to the Forms Designer in the Windows Forms Dialogs project. 2. Drag another Button control from the Toolbox and drop it beneath the Open button and set its properties as follows Set Name to btnSave. Set Anchor to Top Right. Set Location to 349 43. Set Text to Save. 3. In the Toolbox scroll down until you see the SaveFileDialog control and then drag and drop it onto your form. The control will be added to the bottom of the workspace in the IDE. 4. Double-click the Save button to bring up its Click event and add the bolded code Private Sub btnSave_Click ByVal sender As _ ByVal e As Handles Set the Save dialog properties With SaveFileDialogl .DefaultExt txt .FileName strFileName .Filter Text Documents .txt .txt All Files . . .Filterindex 1 .OverwritePrompt True .Title Demo Save File Dialog End With Show the Save dialog and if the user clicks the Save button save the file If Then Try Save the file path and name strFileName Catch ex As Exception _ End Try End if End Sub 5. Right-click in the blank space inside the Try block statement right before the Catch block statement and choose Insert Snippet from the context menu. In the drop-down menu that appears double-click Fundamentals-Collections Data Types File System Math and then in the new list double-click File System-Processing Drives Folders and Files. Finally scroll down the list and double-click Write Text to a File. Your code should now look as follows and you ll notice that the filename C is bolded as is the text string Text indicating that this code needs to be changed Try Save the file path and name strFileName C Text True Catch ex As Exception Prepared for STEPHEN .

crossorigin="anonymous">
Đã 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.