|
-
March 8th, 2011, 06:39 AM
#1
VB6 - Pie Chart
I have written the following code to draw a pie chart in picture box and the code is working fine if it is put inside button click. But the same code is not working in form load. Neither it is throwing some error. Can anyone tel why it is like that?
Private Sub Form_Load()
Picture1.BackColor = &H8000000E
Picture1.ScaleMode = vbPixels
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
With conn
.Provider = "Microsoft.JET.OLEDB.4.0"
.Open "C:\Class database\CLASS.mdb"
End With
Dim sql As String
If rs.State = adStateOpen Then rs.Close
sql = "Select * from "
rs.Open sql, conn, adOpenStatic, adLockBatchOptimistic
Dim rs1 As New ADODB.Recordset
If rs1.State = adStateOpen Then rs.Close
sql = "Select * from "
rs1.Open sql, conn, adOpenStatic, adLockBatchOptimistic
Dim rs2 As New ADODB.Recordset
If rs2.State = adStateOpen Then rs.Close
sql = "Select * from "
rs2.Open sql, conn, adOpenStatic, adLockBatchOptimistic
Dim rs3 As New ADODB.Recordset
If rs3.State = adStateOpen Then rs.Close
sql = "Select * from "
rs3.Open sql, conn, adOpenStatic, adLockBatchOptimistic
Dim rs4 As New ADODB.Recordset
If rs4.State = adStateOpen Then rs.Close
sql = "Select * from "
rs4.Open sql, conn, adOpenStatic, adLockBatchOptimistic
Dim w, x, y, z, z1 As Double
w = rs.RecordCount
x = rs1.RecordCount
y = rs2.RecordCount
z = rs3.RecordCount
z1 = rs4.RecordCount
Dim xx, yy, zz, uu As Double
If w = 0 Then MsgBox "There are no records for" & DateTime.Date & "to be displayed"
If w > 0 Then
xx = (x * 100) / w
yy = xx + (y * 100) / w
zz = yy + (z * 100) / w
uu = zz + (z1 * 100) / w
Call DrawPiePiece(QBColor(1), 0.001, xx)
Call DrawPiePiece(QBColor(6), xx, yy)
Call DrawPiePiece(QBColor(3), yy, zz)
Call DrawPiePiece(QBColor(5), zz, uu)
End If
End Sub
Public Sub DrawPiePiece(lColor As Long, ByVal fStart As Double, ByVal fEnd As Double)
Const PI As Double = 3.14159265359
Const CircleEnd As Double = -2 * PI
Dim dStart As Double
Dim dEnd As Double
Picture1.FillColor = lColor
Picture1.FillStyle = 0
dStart = fStart * (CircleEnd / 100)
dEnd = fEnd * (CircleEnd / 100)
Picture1.Circle (170, 150), 100, , dStart, dEnd
End Sub
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
|