Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah aplikasi yang bisa menampilkan grafik menggunakan software visual basic 6.0. grafik yang dibuat bukanlah grafik yang berjalan secara realtime namun grafik ini bersifat statis yang mana inputnya tergantung pada nilai yang diberikan pada text box. untuk lebih jelasnya berikut adalah programnya.
a. Step Import Chart
b. Program VB 6.0 Menampilkan Grafik
Dim numa As Single
Dim numb As Single
Dim numc As Single
Dim numd As Single
Dim nume As Single
Dim stra As String
Dim strb As String
Dim strc As String
Dim strd As String
Dim stre As String
Dim straa As String
Dim strbb As String
Dim strcc As String
Dim strdd As String
Dim stree As String
Private Sub Command1_Click()
straa = Text1.Text
strbb = Text2.Text
strcc = Text3.Text
strdd = Text4.Text
stree = Text5.Text
stra = Text6.Text
strb = Text7.Text
strc = Text8.Text
strd = Text9.Text
stre = Text10.Text
numa = Val(stra)
numb = Val(strb)
numc = Val(strc)
numd = Val(strd)
nume = Val(stre)
strf = Text11.Text
strg = Text12.Text
strh = Text13.Text
stri = Text14.Text
strj = Text15.Text
numf = Val(strf)
numg = Val(strg)
numh = Val(strh)
numi = Val(stri)
numj = Val(strj)
MSChart1.chartType = Combo1.ListIndex
'2D array --> chart values
Dim x(1 To 6, 1 To 3) As Variant
x(1, 2) = "ARGO BROMO"
x(1, 3) = "ARGO ANGGREK"
x(2, 1) = straa
x(2, 2) = numa
x(2, 3) = numf
x(3, 1) = strbb
x(3, 2) = numb
x(3, 3) = numg
x(4, 1) = strcc
x(4, 2) = numc
x(4, 3) = numh
x(5, 1) = strdd
x(5, 2) = numd
x(5, 3) = numi
x(6, 1) = stree
x(6, 2) = nume
x(6, 3) = numj
'2D array --> chart data
MSChart1.ChartData = x
End Sub
Private Sub Form_Load()
'List Combo: chart types
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"
.ListIndex = 3
End With
Check1.Caption = "&Show Legends"
End Sub
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
Dim numb As Single
Dim numc As Single
Dim numd As Single
Dim nume As Single
Dim stra As String
Dim strb As String
Dim strc As String
Dim strd As String
Dim stre As String
Dim straa As String
Dim strbb As String
Dim strcc As String
Dim strdd As String
Dim stree As String
Private Sub Command1_Click()
straa = Text1.Text
strbb = Text2.Text
strcc = Text3.Text
strdd = Text4.Text
stree = Text5.Text
stra = Text6.Text
strb = Text7.Text
strc = Text8.Text
strd = Text9.Text
stre = Text10.Text
numa = Val(stra)
numb = Val(strb)
numc = Val(strc)
numd = Val(strd)
nume = Val(stre)
strf = Text11.Text
strg = Text12.Text
strh = Text13.Text
stri = Text14.Text
strj = Text15.Text
numf = Val(strf)
numg = Val(strg)
numh = Val(strh)
numi = Val(stri)
numj = Val(strj)
MSChart1.chartType = Combo1.ListIndex
'2D array --> chart values
Dim x(1 To 6, 1 To 3) As Variant
x(1, 2) = "ARGO BROMO"
x(1, 3) = "ARGO ANGGREK"
x(2, 1) = straa
x(2, 2) = numa
x(2, 3) = numf
x(3, 1) = strbb
x(3, 2) = numb
x(3, 3) = numg
x(4, 1) = strcc
x(4, 2) = numc
x(4, 3) = numh
x(5, 1) = strdd
x(5, 2) = numd
x(5, 3) = numi
x(6, 1) = stree
x(6, 2) = nume
x(6, 3) = numj
'2D array --> chart data
MSChart1.ChartData = x
End Sub
Private Sub Form_Load()
'List Combo: chart types
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"
.ListIndex = 3
End With
Check1.Caption = "&Show Legends"
End Sub
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
c. Cara Menjalankan Program
1. Input nilai pada text box yang tersedia
2. Tekan tombol start untuk memulai
3. Jika ingin melihat deskripsi grafik maka cek list pada "legend"
4. Jika ingin merubah jenis grafik maka pilih pada combo box
5. Jika ingin close tekan tombol close pada pojok atas
No comments:
Post a Comment