VB programming

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

  1. 👍 0
  2. 👎 0
  3. 👁 88
asked by Lee
  1. Not sure if you have the latest version of code, because it doesn't compile.
    Inside of the for-loop, you have DrawLines instead of DrawLine, and the calculations have to be cast as integers.

    Once that's done, the axes seem to show properly, which means that you understand how the DrawLine function works.

    Then you need to calculate the starting and end points of each line segment, not forgetting that for a line chart, the end-point of one segment is the beginning of another segment. Right now, the lines are not joining each other.
    Also, the size of the picBox is probably left to default. Since you are "hardcoding" the axes, you may want to define the size of the picBox inside the sub-program using picBox.width=.... etc.

    Give it another try. You're not far.

    1. 👍 0
    2. 👎 0
    posted by MathMate
  2. Okay, I understand what you've advised somewhat, but was wondering if you can give a simple example of the line segments. I kind of based this off of a bar chart I created. Thanks..

    1. 👍 0
    2. 👎 0
    posted by Stacy
  3. maximum value called

    1. 👍 0
    2. 👎 0
    posted by kalpesh

Respond to this Question

First Name

Your Response

Similar Questions

  1. Math (Programming)

    You will need to create a program that will help solve any One-to-One cipher. That is a cipher that replaces each letter in the alphabet with another letter. It is not the same as a Caesar Cipher in that there is no shift. Each

    asked by Anonymous on April 2, 2019
  2. computers

    I have just started a basic class in programming and I am totally lost. Can someone help me out? I have to write pseudocodes and create flowchart and don't have a clue. I need help with the following: flowchart, pseudo-code, Input

    asked by Shawn on April 30, 2010
  3. C++

    // Program: name of program // Author: your name // Date Written: date you began writing the program /* Abstract: Brief description of the program */ Include in-line comments in the body of your program. You can convert

    asked by Frank on September 23, 2016
  4. Ms Visio

    • 2. Construct a data dictionary and draw a hierarchy chart and flowchart or pseudocode for a program to calculate commissions. Output. Output is the commission report shown in the spacing chart that follows. At most, 50 detail

    asked by afroz on September 20, 2011
  5. Programming

    Here is the question that I need help to write the code for the following program in Visual Basic 2010. I am trying to write the code but it has a run time error. If your could helps me to write the code it would be greatly

    asked by Solomon on May 18, 2011
  6. computer programming

    Construct a structure chart, as well as a flowchart and pseudocode, for the following problem. Assume that each input record contains a taxpayer’s name, the value of a personal property belonging to the taxpayer, and a code

    asked by nina on March 22, 2010
  7. c programming

    a student designed a program to accept the age of an employee and then compute the employees retirement year and display the same in a statement on the screen required. a) write out the pseudo-code for the program above b) write

    asked by riley on October 14, 2014
  8. PROGRAMMING

    PLS, I NEED TO BE GUIDED ON HOW TO WRITE A SIMPLE PROGRAM IN BASIC THAT WOULD PROMPT 3 LEVELS OF AUTHENTICATION WHEN UNAUTHORISED LOG-ON IS EFFECTED. You are not going to be able here to get detailed help on the program code, as

    asked by UZOWULU CHARLES on April 23, 2007
  9. computer programming

    small startup software developer company needs to create a program that will calculate the pay of its employees. For the third version of the program, the company wants the program to accept an employee’s name, the number of

    asked by jesse on January 29, 2011
  10. computer

    Create a new project Lab05e, and write a program that asks the user to enter a line. The program must find the one or more words between quotation marks (“”) characters and print them as follows: Please enter a line: She

    asked by eric on October 29, 2010

More Similar Questions