LightSource Collection Example

The following example sets the coordinates and intensity for a light source, then adds a light source from a chart. To try the example, draw an MSChart, and two CommandButton controls on a form. Paste the code into the Form object's code module and run the project. Click the buttons to change the light sources.

Option Explicit

Private Sub Form_Load()
   ' Configure the chart and its light source.
   With MSChart1
      .chartType = VtChChartType3dBar
      .Plot.Light.AmbientIntensity = 0.01 ' 1 % Intensity.
      .Plot.Light.EdgeIntensity = 0.5      ' 50 % Intensity.
      .Plot.Light.EdgeVisible = True
   End With
End Sub

Private Sub Command1_Click()
   Dim LightSource As Object
   Set LightSource = _
   MSChart1.Plot.Light.LightSources(1)
   ' Set coordinates for Light Source 1 as well as its
   ' intensity.
   LightSource.X = 1
   LightSource.y = 0.5
   LightSource.Z = 1
   LightSource.Intensity = 1
End Sub

Private Sub Command2_Click()
   ' Add a new light source.
   MSChart1.Plot.Light.LightSources.Add 0.5, 0.1, 1, 1
End Sub