Cara Membuat Program Simpangan Baku
1. Buka visual basic, pilih new project dan pilih standart exe
2. Lalu tambahkan 1list, 3label, 4 textbox, 2 command
Private Sub Command1_Click()
Dim i, K, value As Integer
Dim STDEV As Double
Dim sigmakuadrat, var, atas, bawah, tbkuadrat, totalbilangan As Long
K = 0
For i = 0 To List1.ListCount - 1
totalbilangan = totalbilangan + Val(List1.List(i))
sigmakuadrat = totalbilangan * totalbilangan
tbkuadrat = tbkuadrat + (Val(List1.List(i)) * Val(List1.List(i)))
K = K + 1
rata = totalbilangan / K
Next
atas = (K * tbkuadrat) - sigmakuadrat
bawah = K * (K - 1)
var = atas / bawah
STDEV = Sqr(var)
Label4.Caption = totalbilangan
Label5.Caption = rata
Label8.Caption = STDEV
End Sub
Private Sub Command2_Click()
Text1.Text = ""
List1.Clear
Label4.Caption = ""
Label5.Caption = ""
Label8.Caption = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Text1_keypress(keyascii As Integer)
Dim i As Integer
i = Val(Text1.Text)
If keyascii = 13 Then
List1.AddItem i
Text1.Text = ""
End If
End Sub
2. Lalu tambahkan 1list, 3label, 4 textbox, 2 command
Private Sub Command1_Click()
Dim i, K, value As Integer
Dim STDEV As Double
Dim sigmakuadrat, var, atas, bawah, tbkuadrat, totalbilangan As Long
K = 0
For i = 0 To List1.ListCount - 1
totalbilangan = totalbilangan + Val(List1.List(i))
sigmakuadrat = totalbilangan * totalbilangan
tbkuadrat = tbkuadrat + (Val(List1.List(i)) * Val(List1.List(i)))
K = K + 1
rata = totalbilangan / K
Next
atas = (K * tbkuadrat) - sigmakuadrat
bawah = K * (K - 1)
var = atas / bawah
STDEV = Sqr(var)
Label4.Caption = totalbilangan
Label5.Caption = rata
Label8.Caption = STDEV
End Sub
Private Sub Command2_Click()
Text1.Text = ""
List1.Clear
Label4.Caption = ""
Label5.Caption = ""
Label8.Caption = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Text1_keypress(keyascii As Integer)
Dim i As Integer
i = Val(Text1.Text)
If keyascii = 13 Then
List1.AddItem i
Text1.Text = ""
End If
End Sub
Komentar
Posting Komentar