Rabu, 14 Maret 2012

Chat Grafik by Vb 6.0

Rancangan form

Code programnya

Dim Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Cunt1, Cunt2 As Integer
Dim i As Integer
Dim dt1, dt2, dt3 As Integer


Private Sub Check1_Click()
If Check1.Value = 1 Then
'Show Legends
MSChart1.ShowLegend = True
Check1.Caption = "&Hide Legends"
Else
'Hide Legends
MSChart1.ShowLegend = False
Check1.Caption = "&Show Legends"
End If
End Sub


Private Sub CmdProsesOK_Click()
Dim X(1 To 8, 1 To 3) As Variant
  X(1, 2) = ""
 MSChart1.ChartData = X
 'MSChart1.chartType = 1
MSChart1.RowCount = Adodc1.Recordset.RecordCount
MSChart1.Row = 1
MSChart1.Column = 1
TimerTitle.Interval = 100
 i = 1
Adodc1.Recordset.MoveFirst
End Sub


Private Sub Combo1_Click()
'untuk mengubah type chart saat run time.
MSChart1.chartType = Combo1.ListIndex
End Sub


Private Sub Command1_Click()
Dim X(1 To 8, 1 To 3) As Variant
  X(1, 2) = ""
 MSChart1.ChartData = X
 'MSChart1.chartType = 1
MSChart1.RowCount = Adodc1.Recordset.RecordCount
MSChart1.Row = 1
MSChart1.Column = 1
Timer1.Interval = 100
 i = 1
Adodc1.Recordset.MoveFirst
End Sub


Private Sub Command2_Click()
FrmAddData.Show
End Sub


Private Sub Command3_Click()
MSChart1.Row = Text3.Text
MSChart1.RowLabel = Text4.Text
End Sub


Private Sub Command4_Click()
MSChart1.RowCount = Text6.Text
MSChart1.ColumnCount = Text5.Text
End Sub


Private Sub Command5_Click()
MSChart1.Data = Text1.Text
MSChart1.Column = Text2.Text
End Sub


Private Sub Form_Load()
 'buka koneksi
    'Conn.CursorLocation = adUseClient
   Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database.mdb"
    Adodc1.RecordSource = "TB_DATA"
   Set DataGrid1.DataSource = Adodc1
   Adodc1.Caption = "Cunt : " & Adodc1.Recordset.RecordCount
 Cunt1 = Adodc1.Recordset.RecordCount

   With Combo1
.AddItem "3D Bar"
.AddItem "2D Bar"
.AddItem "3D Line"
.AddItem "2D LIne"
.AddItem "3D Area"
.AddItem "2D Area"
.AddItem "3D Step"
.AddItem "2D Step"
.AddItem "3D Combination"
.AddItem "2D Combination"
End With
End Sub


Private Sub Form_Resize()
On Error Resume Next
MSChart1.Height = Me.Height - 3525
MSChart1.Width = Me.Width - 3420
Combo1.Top = MSChart1.Height + 20
Check1.Top = MSChart1.Height + 40
Command1.Top = MSChart1.Height + 20
Command2.Top = MSChart1.Height + 20
CmdProsesOK.Top = MSChart1.Height + 20
DataGrid1.Top = MSChart1.Height + 600
Adodc1.Top = MSChart1.Height + (DataGrid1.Height + 600)

Frame1.Left = MSChart1.Width + 200
Frame2.Left = MSChart1.Width + 200
Frame3.Left = MSChart1.Width + 200

End Sub


Private Sub Timer1_Timer()
Text3.Text = i
 With MSChart1
     .RowLabel = Adodc1.Recordset!KELURAHAN
     If .Row <= Adodc1.Recordset.RecordCount Then
     .Row = .Row + 1
     End If
 End With
 i = i + 1
  Adodc1.Recordset.MoveNext
 If MSChart1.Row = Adodc1.Recordset.RecordCount Then
 Timer1.Interval = 0
 MSChart1.RowLabel = Adodc1.Recordset!KELURAHAN
 Timer2.Interval = 1500
 Adodc1.Recordset.MoveFirst
 MSChart1.Row = 1
 End If
End Sub


Private Sub Timer2_Timer()

MSChart1.Column = 1
MSChart1.Data = Adodc1.Recordset!datang
MSChart1.ColumnLabel = "DATANG"

MSChart1.Column = 2
MSChart1.Data = Adodc1.Recordset!Meninggal
MSChart1.ColumnLabel = "MENINGGAL"

MSChart1.Column = 3
MSChart1.Data = Adodc1.Recordset!pindah
MSChart1.ColumnLabel = "MUTASI"

Adodc1.Recordset.MoveNext
On Error Resume Next
MSChart1.Row = MSChart1.Row + 1
If Adodc1.Recordset.EOF Then Timer2.Interval = 0
End Sub


Private Sub Timer3_Timer()
TimerC1.Enabled = True
dt1 = 0
dt2 = 0
dt3 = 0

Adodc1.Recordset.MoveNext
On Error Resume Next
MSChart1.Row = MSChart1.Row + 1
Timer3.Interval = 0
If Adodc1.Recordset.EOF Then Timer3.Interval = 0
End Sub


Private Sub TimerC1_Timer()
dt1 = dt1 + 1
MSChart1.Column = 1
MSChart1.Data = dt1
If dt1 >= Val(Adodc1.Recordset!datang) Then
MSChart1.ColumnLabel = "DATANG"
TimerC1.Enabled = False
TimerC2.Enabled = True
dt1 = 0
dt2 = 0
dt3 = 0
End If
End Sub


Private Sub TimerC2_Timer()
dt2 = dt2 + 1
MSChart1.Column = 2
MSChart1.Data = dt2
If dt2 = Val(Adodc1.Recordset!Meninggal) Then
MSChart1.ColumnLabel = "MENIGGAL"
TimerC2.Enabled = False
TimerC3.Enabled = True
dt1 = 0
dt2 = 0
dt3 = 0
End If
End Sub


Private Sub TimerC3_Timer()
dt3 = dt3 + 1
MSChart1.Column = 3
MSChart1.Data = dt3
If dt3 = Val(Adodc1.Recordset!pindah) Then
MSChart1.ColumnLabel = "PINDAH"
TimerC3.Enabled = False
If Not Adodc1.Recordset.AbsolutePosition = Adodc1.Recordset.RecordCount Then
Timer3.Interval = 100
End If
dt1 = 0
dt2 = 0
dt3 = 0
End If
End Sub


Private Sub TimerTitle_Timer()
Text3.Text = i
 With MSChart1
     .RowLabel = Adodc1.Recordset!KELURAHAN
     If .Row <= Adodc1.Recordset.RecordCount Then
     .Row = .Row + 1
     End If
 End With
 i = i + 1
  Adodc1.Recordset.MoveNext
 
 If MSChart1.Row = Adodc1.Recordset.RecordCount Then
 TimerTitle.Interval = 0
 MSChart1.RowLabel = Adodc1.Recordset!KELURAHAN
 'Timer3.Interval = 1000
 Adodc1.Recordset.MoveFirst
 MSChart1.Row = 1
 TimerC1.Enabled = True
dt1 = 0
dt2 = 0
dt3 = 0
 End If
End Sub


Tidak ada komentar:

Posting Komentar