Jumat, 08 Juni 2012

Example of Visual Basic Application

Initial



Coding


Private Sub Combo1_LostFocus()
Text1.Text = ""
Text1.SetFocus
End Sub

Private Sub Command1_Click()
i = Val(Text1.Text)
If i < 1 Then
MsgBox "Usia Minimal Adalah 1", vbQuestion, "INPUT SALAH"
Else
    If i > 150 Then
    MsgBox "Usia Terlalu Tua", vbQuestion, "INPUT SALAH"
    Else
        If Not i = Int(i) Then
        MsgBox "Usia Harus Merupakan Bilangan Bulat", vbQuestion, "INPUT SALAH"
        Else
       
If Combo1.Text = "Laki-Laki" Then

If i >= 1 And i < 7 Then
w = i
x = 55.6
r = 10.3
Else
    If i >= 7 And i < 16 Then
    w = i - 6
    x = 114.75
    r = 5.27
    Else
        If i >= 16 And i < 20 Then
        w = i - 15
        x = 164
        r = 1.1
        Else
            If i >= 20 And i < 23 Then
            w = i - 19
            x = 168.4
            r = 0.3
            Else
                If i >= 23 And i < 26 Then
                w = i - 22
                x = 169.3
                r = 0.1
                Else
                    If i >= 26 And i < 40 Then
                    w = i - 25
                    x = 169.5
                    r = 0
                    Else
                        If i >= 40 And i < 66 Then
                        w = i - 39
                        x = 169.5
                        r = -0.15
                        Else
                            w = i - 65
                            x = 165.76
                            r = -0.01
                        End If
                    End If
                End If
            End If
        End If
    End If
End If

Else
If i >= 1 And i < 6 Then
w = i
x = 55.6
r = 9.9
Else
    If i >= 6 And i < 13 Then
    w = i - 5
    x = 110
    r = 5.33
    Else
        If i >= 13 And i < 19 Then
        w = i - 12
        x = 148
        r = 1.1
        Else
            If i >= 19 And i < 21 Then
            w = i - 18
            x = 156.5
            r = 0.2
            Else
                If i >= 21 And i < 23 Then
                w = i - 22
                x = 157
                r = 0.1
                Else
                    If i >= 23 And i < 35 Then
                    w = i - 22
                    x = 157.3
                    r = 0
                    Else
                        If i >= 35 And i < 61 Then
                        w = i - 34
                        x = 157.3
                        r = -0.09
                        Else
                            w = i - 60
                            x = 155.06
                            r = -0.01
                        End If
                    End If
                End If
            End If
        End If
    End If
End If

End If

If Combo1.Text = "Laki-Laki" Then

If i >= 1 And i < 7 Then
wlb = i
xlb = 12.9
rlb = 2.1
Else
    If i >= 7 And i < 18 Then
    wlb = i - 6
    xlb = 25.35
    rlb = 1.15
    Else
        If i >= 18 And i < 41 Then
        wlb = i - 17
        xlb = 38.74
        rlb = 0.26
        Else
            wlb = i - 40
            xlb = 44.97
            rlb = -0.09
        End If
    End If
End If

Else
If i >= 1 And i < 7 Then
wlb = i
xlb = 13
rlb = 2
Else
    If i >= 7 And i < 13 Then
    wlb = i - 6
    xlb = 25.125
    rlb = 1.375
    Else
        If i >= 13 And i < 17 Then
        wlb = i - 12
        xlb = 31.45
        rlb = 0.85
        Else
            If i >= 17 And i < 36 Then
            wlb = i - 16
            xlb = 34.05
            rlb = 0.05
            Else
                wlb = i - 35
                xlb = 35.03
                rlb = -0.05
            End If
        End If
    End If
End If

End If

If Combo1.Text = "Laki-Laki" Then

If i >= 1 And i < 8 Then
wlp = i
xlp = 10.51
rlp = 1.28
Else
    If i >= 8 And i < 12 Then
    wlp = i - 7
    xlp = 19.23
    rlp = 0.76
    Else
        If i >= 12 And i < 16 Then
        wlp = i - 11
        xlp = 22.93
        rlp = 0.76
        Else
           If i >= 16 And i < 41 Then
            wlp = i - 15
            xlp = 26.6
            rlp = 0.33
            Else
                wlp = i - 40
                xlp = 35
                rlp = -0.03
            End If
        End If
    End If
End If

Else
If i >= 1 And i < 8 Then
wlp = i
xlp = 9.78
rlp = 1.3
Else
    If i >= 8 And i < 12 Then
    wlp = i - 7
    xlp = 19.13
    rlp = 0.96
    Else
        If i >= 12 And i < 16 Then
        wlp = i - 11
        xlp = 22.56
        rlp = 0.73
        Else
            If i >= 16 And i < 36 Then
            wlp = i - 15
            xlp = 25.527
            rlp = 0.073
            Else
                wlp = i - 35
                xlp = 27
                rlp = -0.05
            End If
        End If
    End If
End If

End If

If Combo1.Text = "Laki-Laki" Then

If i >= 1 And i < 7 Then
wld = i
xld = 30.96
rld = 4.34
Else
    If i >= 7 And i < 18 Then
    wld = i - 6
    xld = 56.33
    rld = 2.66
    Else
        If i >= 18 And i < 40 Then
        wld = i - 17
        xld = 83.9
        rld = 0.595
        Else
            wld = i - 39
            xld = 97.05
            rld = -0.05
        End If
    End If
End If

Else
If i >= 1 And i < 7 Then
wld = i
xld = 31.12
rld = 3.98
Else
    If i >= 7 And i < 17 Then
    wld = i - 6
    xld = 55
    rld = 2
    Else
        If i >= 17 And i < 36 Then
        wld = i - 16
        xld = 77.335
        rld = 0.164
        Else
            wld = i - 35
            xld = 80.8
            rld = -0.05
        End If
    End If
End If

End If

        End If
    End If
End If
For jlp = 0 To wlp Step 1
dxlp = jlp * rlp
Next jlp
For jld = 0 To wld Step 1
dxld = jld * rld
Next jld
For jlb = 0 To wlb Step 1
dxlb = jlb * rlb
Next jlb
For j = 0 To w Step 1
dx = j * r
Next j
t = x + dx
b = 0.00215 * t ^ 2
tlb = xlb + dxlb
tlp = xlp + dxlp
tld = xld + dxld
Label12.Caption = tlp
Label14.Caption = tld
Label11.Caption = tlb
Label1.Caption = t
Label6.Caption = b
Label16.Caption = "untuk " & Combo1.Text & " berusia " & i & " tahun"
If i < 1 Then
Label16.Caption = "Usia Minimal Adalah 1"
Else
    If i > 150 Then
    Label16.Caption = "Usia Terlalu Tua"
    Else
        If Not i = Int(i) Then
        Label16.Caption = "Usia Harus Merupakan Bilangan Bulat"
        End If
    End If
End If
Text1.Text = ""
Text1.SetFocus
End Sub

Private Sub Command2_Click()
MsgBox "Terima Kasih Telah Menggunakan Aplikasi Ini", vbInformation, "TERIMA KASIH"
MsgBox "Penelitian Antropometri oleh FISIP UNAIR April 2011", vbQuestion, "SUMBER DATA"
Unload Me
End Sub

Private Sub Form_Load()
MsgBox "Selamat Datang di Aplikasi Pengukur Tubuh Proporsional                   ---KARYA LURI, DIMAS, NINDA, TERRY---", vbInformation, "PERHATIAN"
Command1.Enabled = False
Combo1.AddItem ("Laki-Laki")
Combo1.AddItem ("Perempuan")
End Sub

Private Sub Text1_Change()
If Combo1.Text = "Jenis Kelamin" Then
MsgBox "Pilih Jenis Kelamin Dahulu", vbInformation, "Perhatian"
Else
Command1.Enabled = True
End If
End Sub


Result






Tidak ada komentar: