20. Write a VB program that takes a set of ten numbers and converts them into either a bar chart or pie chart using appropriate button. For a bar chart you must scale your values to make the best use of available space. Before drawing the bars, find the largest number in the cell. (Use this largest number and height of display area to workout suitable scale factor.)


Private Sub CmdBar_Click()
If Option1.Value Then
MSChart1.chartType = VtChChartType2dBar
Else
MSChart1.chartType = VtChChartType3dBar
End If
MSChart1.RowCount = 10
MSChart1.ColumnCount = 1
For i = 1 To 10
MSChart1.Row = i
MSChart1.Column = 1
MSChart1.Data = InputBox(“Enter Data: ” + Str(i) + “: “, “Data”)
MSChart1.RowLabel = “D” + Str(i)
Next
End Sub
Private Sub CmdPie_Click()
MSChart1.chartType = VtChChartType2dPie
MSChart1.RowCount = 1
MSChart1.ColumnCount = 10
For i = 1 To 10
MSChart1.Row = 1
MSChart1.Column = i
MSChart1.Data = InputBox(“Enter Data: ” + Str(i) + “: “, “Data”)
Next
End Sub
Private Sub CmdExit_Click()
End
End Sub
Private Sub Form_Load()
MSChart1.Visible = True
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s