Rendy Dwi Ardiansyah Putra 7410040018 / 2 D4 IT A Statistika
STATISTIKA DAN PROBABILITAS
1.
Program Menghitung Menghitung Min, Max, Sum, Mean, Modus, dan Median kemudian di tamplikan dalam bentuk Chart.
Tampilan Program:
Setelah Program dijalankan:
Tampilan Program dalam bentuk Chart:
Source Code Form1:
Private Sub Form_Load() Skin1.ApplySkin Skin1.ApplySkin hWnd End Sub
Private Sub Text1_KeyPress(KeyAscii Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then If Not IsNumeric(Text1.Text) Then MsgBox ("masukan angka bukan huruf") Else List1.AddItem List1.AddItem (Text1.Text) total = total + Val(Text1.Text) Val(Text1.Text) rata = total / List1.ListCount X = List1.ListCount / 2
If List1.ListCount = 1 Then max = Text1.Text min = Text1.Text End If
If max < Val(Text1.Text) Then max = Text1.Text End If
If min > Val(Text1.Text) Then min = Text1.Text End If
If List1.ListCount = X Then median = List1.ListCount End If
Text2.Text = min Text3.Text = max Text4.Text = total Text5.Text = rata Text7.Text = median
If List1.ListCount = 1 Then ReDim Preserve nilai(0) ReDim Preserve freq(0) nilai(0) = Text1.Text freq(0) = 1
Else Dim ada As Boolean
For i = 0 To UBound(nilai)
If Text1.Text = nilai(i) Then freq(i) = freq(i) + 1 ada = True Exit For End If Next
If Not ada Then
ReDim Preserve nilai(i) ReDim Preserve freq(i) nilai(i) = Text1.Text freq(i) = 1 End If
Dim tmp1 As Single, tmp2 As Single
For k = 0 To UBound(nilai) If k = 0 Then tmp1 = nilai(k) tmp2 = freq(k)
ElseIf freq(k) > tmp2 Then tmp1 = nilai(k) tmp2 = freq(k) End If Text6.Text = tmp1
Next End If Text1.Text = "" Text1.SetFocus End If
End If
If List1.ListCount = 8 Then Form2.Show End If End Sub
Source Code Form2: Private Sub Form_Load() Skin1.ApplySkin Skin1.ApplySkin hWnd
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" Combination"
.AddItem "2D Combination" Combination" End With
'End Sub 'Mendeklarasikan 'Mendeklarasikan variabel 2D array untuk menyimpan nilai dari chart
Dim X(1 To 2, 1 To 9) As Variant
X(1, 2) = "data - 1" X(1, 3) = "data - 2" X(1, 4) = "data - 3" X(1, 5) = "data - 4" X(1, 6) = "data - 5" X(1, 7) = "data - 6" X(1, 8) = "data - 7" X(1, 9) = "data - 8"
'On Error Resume Next
X(2, 1) = "DATA" X(2, 2) = CInt(Form1.List1.List(0)) CInt(Form1.List1.List(0)) X(2, 3) = CInt(Form1.List1.List(1)) CInt(Form1.List1.List(1)) X(2, 4) = CInt(Form1.List1.List(2)) CInt(Form1.List1.List(2)) X(2, 5) = CInt(Form1.List1.List(3)) CInt(Form1.List1.List(3)) X(2, 6) = CInt(Form1.List1.List(4)) CInt(Form1.List1.List(4)) X(2, 7) = CInt(Form1.List1.List(5)) CInt(Form1.List1.List(5)) X(2, 8) = CInt(Form1.List1.List(6)) CInt(Form1.List1.List(6)) X(2, 9) = CInt(Form1.List1.List(7)) CInt(Form1.List1.List(7))
'2D array merupakan data untuk chart control. MSChart1.ChartData MSChart1.ChartData = X 'Default chart type adalah 2D bar chart. MSChart1.chartType = 1
'Label1.Caption 'Label1.Caption = Form1.List1.List(1) Form1.List1.List(1) 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 Private Sub Combo1_Click()
'untuk mengubah type chart saat run time. MSChart1.chartType = Combo1.ListIndex End Sub