TAILIEUCHUNG - Mastering Excel 2003 Programming with VBA phần 9

Limit Limit là một tham số tùy chọn có thể được sử dụng để xác định có bao nhiêu subparts trở lại. So sánh So sánh là một tham số tùy chọn có thể được sử dụng để xác định loại so sánh để sử dụng khi so sánh chuỗi con. Sử dụng một trong những điều sau đây | forms are meant to be shown 469 There isn t much to this one is there Granted this is a simple form but usually the code in the event procedures associated with the various controls on a form is fairly compact. Every form you create will use either the Activate or Initialize event to populate its controls before the form actually gets displayed to the user. The Initialize event only occurs once in a form s lifetime it is the first thing to happen when a form gets created. The Activate event can occur multiple times in a form s lifetime. An Activate event typically though not necessarily occurs just after the Initialize event. You ll see the difference between these two events later in the chapter in the section titled The Form Lifecycle. For now you can see that I ve used the Initialize event to populate the text box with the name of the active sheet and then preselected the text in the text box. If I didn t preselect the text the cursor would appear at the end of the text which is not very convenient from a user s perspective. The only other comment I have regarding this listing is that the SaveSheetName procedure is called by the cmdOK click event procedure. In order to keep it simple I m not bothering to check if the user actually changes the sheet name or not. I mean what s the point Does it make a difference if the sheet name is set to the exact same value I think not. Also rather than worry about validating the name entered it is much easier to let Excel do the validating for me and just continue on my business if an error occurs. If this were a production type application I would probably want to inspect any error that does occur so that I can notify the user why the name couldn t be changed. Forms Are Meant to Be Shown Of course you can t expect your users to open the VBE select the form they want to run and then press F5 to run it. You need some way to allow them to see the form or show it when certain events happen. Depending on your needs you have a few

Đã 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.