•  
  •  
  •  
 

To Glenn...

Last post 24 Apr 2007, 8:16 PM by PMcM. 1 replies.
Sort Posts: Previous Next
  •  15 May 2003, 3:04 PM 4510

    To Glenn...

    Hi Glenn,

    Thanks for replying.

    I don't really quite understand the codes that you provide.
    Maybe I should describe more on the situation.

    I hope to create a mouse over effect on the points that I have plot.
    Refer to the pic below: When my cursor is place on the point (red/blue dot), it should change to another color.

    [img]c:/Sample.gif[/img]

    Below is the source code:
    **************************************

    'Declare global variables
    'These hold random data values
    Dim DataValues(1 To 5) As Long
    Dim Line1Values(0 To 11) As Long
    Dim Line2Values(0 To 11) As Long

    'These are arrays of month names and colours
    Dim Colours
    Dim Months

    'Draw a bar chart
    Private Sub DrawBarChart()
    Dim I As Long
    With Draw1

    'Restore some default properties that might have been changed
    .YGrad = 0
    .YTop = 0
    .OriginY = 250
    .YAxisNegative = 0

    'Graph is a vertical bar chart
    .GraphType = dgtVBar

    'Set some properties based on the check boxes
    .ShowGrid = Check1.Value
    .ShowLegend = Check2.Value
    If Check3.Value Then
    .PlotAreaColor = &HEEEEEE
    Else
    .PlotAreaColor = vbWhite
    End If
    .ShowBarTotal = Check4.Value
    .UseRNDColor = Check5.Value

    'Add the data values
    For I = 1 To 5
    .AddData "Item" + Str(I), DataValues(I), Colours(I - 1)
    Next I

    'Draw the graph
    .DrawGraph
    End With
    End Sub

    'Draw a pie chart
    Private Sub DrawPieChart()
    Dim I As Long
    With Draw1
    'Graph is a pie chart
    .GraphType = dgtPie

    'Set some properties based on the check boxes
    .ShowLabel = Check6.Value
    .ShowNumbers = Check7.Value
    .ShowPercent = Check8.Value
    .ShowLegend = Check9.Value
    .UseRNDColor = Check10.Value

    'Add the data values
    For I = 1 To 5
    .AddData "Item" + Str(I), DataValues(I), Colours(I - 1)
    Next I

    'Draw the graph
    .DrawGraph
    End With
    End Sub

    'Draw a line graph
    Private Sub DrawLineGraph()
    Dim I As Long
    With Draw1
    'Graph is a line graph
    .GraphType = dgtLine

    'Set the origin and axes
    .OriginY = 150
    .YAxisNegative = 100
    .YTop = 50
    .YGrad = 10
    .XTop = 11
    .XGrad = 1

    'Set some properties based on the check boxes
    If Check11 Then
    .LineWidth = 2
    Else
    .LineWidth = 1
    End If
    If Check12 Then
    .PointSize = 4
    .PointStyle = dgpsDot
    Else
    .PointSize = 0
    End If
    .ShowLine = Check13.Value
    .ShowGrid = Check14.Value
    .ShowLegend = Check15.Value

    'This option replaces the x-axis values with the values
    'of the Months array
    If Check16 Then
    .UseXAxisLabels = True
    For I = 0 To 11
    .AddXValue I, Months(I)
    Next I
    Else
    .UseXAxisLabels = False
    End If

    'Add the data points
    For I = 0 To 11
    .AddPoint I, Line1Values(I), vbRed, "Line 1"
    .AddPoint I, Line2Values(I), vbBlue, "Line 2"
    Next I

    'Draw the graph
    .DrawGraph
    End With
    End Sub

    Private Sub Command1_Click()
    'Clear any previously entered data
    Draw1.ClearData

    'Check which graph to draw
    If Option1(0).Value Then
    Call DrawBarChart
    End If
    If Option1(1).Value Then
    Call DrawPieChart
    End If
    If Option1(2).Value Then
    Call DrawLineGraph
    End If
    End Sub

    Private Sub Command2_Click()
    'Generate some random data for bar and pie charts
    Dim I As Long
    Randomize
    List1.Clear
    For I = 1 To 5
    DataValues(I) = Int(100 * Rnd())
    List1.AddItem ("Item " + Str(I) + " : " + Str(DataValues(I)))
    Next I

    'Enable the button for drawing graphs
    Command1.Enabled = True
    Command1.SetFocus
    End Sub

    Private Sub Command3_Click()
    'Generate some random points for plotting 2 lines on a graph
    Dim I As Long
    Randomize
    List2.Clear
    List3.Clear
    For I = 0 To 11
    Line1Values(I) = Int(100 * Rnd()) - 50
    Line2Values(I) = Int(100 * Rnd()) - 50
    List2.AddItem ("(" + Str(I) + ", " + Str(Line1Values(I)) + ")")
    List3.AddItem ("(" + Str(I) + ", " + Str(Line2Values(I)) + ")")
    Next I

    'Enable the button for drawing graphs
    Command1.Enabled = True
    Command1.SetFocus
    End Sub

    Private Sub Form_Load()
    'Initialise some things
    Colours = Array(vbRed, vbBlue, vbGreen, vbMagenta, vbYellow)
    Months = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    Command1.Enabled = False
    Command3.Enabled = False
    End Sub

    Private Sub Label8_Click()
    Draw1.AboutBox
    End Sub

    Private Sub Option1_Click(Index As Integer)
    'Enable and disable buttons as different graph options are selected
    'Clear list boxes of data values when finished with
    If Index = 0 Or Index = 1 Then
    List2.Clear
    List3.Clear
    Command3.Enabled = False
    Command2.Enabled = True
    If List1.ListCount = 0 Then
    Command1.Enabled = False
    End If
    Else
    List1.Clear
    Command2.Enabled = False
    Command3.Enabled = True
    If List2.ListCount = 0 Then
    Command1.Enabled = False
    End If
    End If

    End Sub

    **************************************

    Do tell me what are the codes and where should I insert it to achieve the requirement.

    Thanks for your guidance.
  •  24 Apr 2007, 8:16 PM 11905 in reply to 4510

    Re: To Glenn...

    Glenn,

     Hi,

    I wonder if you can help me with an assignment I am doing which has to be done by next week. The reason I am e mailing you is to see if you can give me much needed help on my assignment.(Visual Basic 6)

    A charity has various fundraising activities such as a cake sales, christmas card selling,running marathons,individual donations, etc.You are required to design and write a program to produce a monthly report that will show monies raised for each activity, each activity has an administration cost(some activities have the same percentage cost) and also showing all monies raised, deducting 5% for overall administration costs.

    For each activity you should produce a report showing each fundraisers name and address, money raised and any other details pertaining to that activity. eg number of cards sold.

    You should allocate different prizes for amounts raised i.e anthing < 100 no prize, CD player if ammount > 100 etc, for each activity. You should produce a report showing all prizes given out.

    All reports should have a title, time an date and be formatted. Include a bar chart to display the monies raised for each activity. Also include a barchart to display the expenses for each activity. Use a two dimensional chart.

    Any ideas

    Thanks

    Pat Mc Mahon

View as RSS news feed in XML