Saturday
July 4, 2015

Homework Help: VB programming

Posted by Lee on Wednesday, December 1, 2010 at 6:19am.

This problem is creating code for a line chart.

- Write a program to create the line chart. Use Table in 9.6:

Table 9.6] Two -year college enrollments (in thousands).

1960 1970 1980 1990 2000
----------------------------------
Male 283 1375 2047 2233 2398
Female 170 945 2479 3007 3358
___________________________________

This is my code: It works but it does not draw the Line with dots. I can't figure it out. Could you help me figure it out? Please

Public Class frmLineChart

Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Dim quantity() As String = {283, 1375, 2047, 2233, 2398, _
170, 945, 2479, 3007, 3358}
Dim gr As Graphics = picBox.CreateGraphics
Dim strVar As String = "Male"
gr.DrawString(strVar, Me.Font, Brushes.Green, 50, 75)
gr.DrawString("Female", Me.Font, Brushes.Orange, 165, 5)
'The picture box has width 210 and height 150
gr.DrawLine(Pens.Black, 40, 110, picBox.Width, 110) 'Draw x-axis
gr.DrawLine(Pens.Black, 40, 110, 40, 1) 'Draw y-axis
gr.DrawLine(Pens.Green, 60, 105, 365, -80) 'Draw tick mark
gr.DrawLine(Pens.Orange, 65, 105, 330, -75) 'Draw tick marks
gr.DrawString("3358", Me.Font, Brushes.Black, 10, 5)

For i As Integer = 0 To quantity.GetUpperBound(0)
gr.DrawLines(Pens.Green, 1199 + i * 40, _
(110 - quantity(i) / 2), 20, quantity(i) / 2)
Next

gr.DrawString("1960 1970 1980 1990 2000", Me.Font, _
Brushes.Black, 50, 115)
gr.DrawString("Two-year college enrollments (in thousands).", Me.Font, _
Brushes.Black, 40, 135)

End Sub
End Class

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

More Related Questions

Members