Thủ tục này sẽ hiển thị một hộp tin nhắn có chứa một mô tả của mục đã chọn. Khi sự kiện Chọn xảy ra, các đối số ElementID chứa một số nguyên tương ứng với những gì đã được lựa chọn. Các ARG1 và Arg2 | Chapter 18 Working with Charts 555 Case xlXErrorBars Id XErrorBars Case xlYErrorBars Id YErrorBars Case xlLegendEntry Id LegendEntry Case xlLegendKey Id LegendKey Case xlAxis Id Axis Case xlMajorGridlines Id MajorGridlines Case xlMinorGridlines Id MinorGridlines Case xlAxisTitle Id AxisTitle Case xlUpBars Id UpBars Case xlDownBars Id DownBars Case xlSeriesLines Id SeriesLines Case xlHiLoLines Id HiLoLines Case xlDropLines Id DropLines Case xlRadarAxisLabels Id RadarAxisLabels Case xlShape Id Shape Case xlNothing Id Nothing Case Else Id Some unknown thing End Select MsgBox Selection type Id End Sub This procedure displays a message box that contains a description of the selected item. When the Select event occurs the ElementID argument contains an integer that corresponds to what was selected. The Arg1 and Arg2 arguments provide additional information about the selected item see the online help for details . The Select Case structure converts the built-in constants to descriptive strings. Enabling events for an embedded chart As I noted in the previous section Chart events are automatically enabled for chart sheets but not for charts embedded in a worksheet. To use events with an embedded chart you need to perform the following steps Create a class module In the VB Editor window select your project in the Project window and select Insert Class Module. This will add a new empty class module to your project. If you like you can use the Properties window to give the class module a more descriptive name. Declare a public Chart object The next step is to declare a Public variable that will be used as the class name. The variable should be of type Chart and it must be declared in the class module using the WithEvents keyword. If you omit the WithEvents keyword the object will not respond to events. Following is an example of such a declaration Public WithEvents myChartClass As Chart 556 Part V Advanced Programming Techniques Connect the declared object with your chart .