|
-
Jul 28th, 2008, 12:01 AM
#1
Thread Starter
New Member
[RESOLVED] [2008] No display with pic object
hello,
i was wondering if anyone could help me with an issue i have with my program. i am trying to create a program that displays a pie chart after the user inputs the numeric values for the sectors of the pies. I get output of the legend, but not the actual pie itself.
Code:
Public Class frmBudget
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Dim housing As Single = 0, transport As Single = 0, _
food As Single = 0, other As Single = 0
Dim sum As Single = 0
Dim housingP As Single = 0, transportP As Single = 0, _
foodP As Single = 0, otherP As Single = 0
Dim percent() As Single = {housingP, transportP, foodP, otherP}
Dim legend() As String = {"Housing", "Transportation", "Food", "Other"}
housing = CSng(txtHousing.Text)
transport = CSng(txtTransportation.Text)
food = CSng(txtFood.Text)
other = CSng(txtOther.Text)
sum = housing + transport + food + other
housingP = housing / sum
transportP = transport / sum
foodP = food / sum
otherP = other / sum
Dim pie As Graphics = picPieChart.CreateGraphics
Dim r As Integer = 115 ' circle radius
Dim c As Integer = 120 'circle center has coordinates (c, c)
Dim sumOfSweepAngles As Single = 0
Dim brush() As Brush = {Brushes.Blue, Brushes.Red, Brushes.Green, Brushes.Yellow}
For i As Integer = 0 To 3
pie.FillPie(brush(i), c - r, c - r, 2 * r, 2 * r, _
sumOfSweepAngles, percent(i) * 360)
sumOfSweepAngles += percent(i) * 360
pie.FillRectangle(brush(i), 350, 20 + 30 * i, 20, 20)
pie.DrawString(legend(i), Me.Font, Brushes.Black, 380, 22 + 30 * i)
Next
End Sub
End Class
thanks in advance to anyone who can help!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|