Tuesday, 4 June 2013

Program Simulasi Rangkaian Listrik Sederhana

Deskripsi Program
Program ini dibuat agar memudahkan penggunanya dalam penghitungan hambatan (resistor), tegangan (voltase), dan arus (current). Dalam permulaan program ini pengguna akan dihadapkan pada 2 pilihan yaitu, rangkaian seri atau rangkaian paralel, tergantung dari kebutuhan pengguna maka program akan berjalan sesuai pilihan tersebut. Pada penghitungan hambatan, didesain hanya untuk 3 masukkan (input) saja untuk menghasilkan keluaran (output) berupa hambatan pengganti (Rs atau Rp). Terdapat perbedaan dalam pemrograman antara rangkaian seri dan paralel, khususnya pada penghitungan hambatannya karena berdasarkan hukum kirchoff yang berlaku, namun dalam penghitugan arus maupun tegangan menggunakan formula yang sama. Maka untuk input yang sama hasil yang didapat pada rangkaian seri dan rangkaian paralel adalah berbeda.

Langkah Pembuatan

1. Buat form seperti di bawah ini :























Ubah properties dari komponen tersebut seperti ini











Lalu masukkan kode berikut :
Public Class Form2
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Hide()
        Form3.Show()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Hide()
        form4.Show()
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CenterToScreen()
    End Sub
End Class

2. Buat form seperti di bawah ini :































Ubah properties dari komponen tersebut seperti ini :
Obyek
Property
Perubahan
Picturebox 1
Image

Label 2
Text
R1 =
Label 3
Text
R2 =
Label 4
Text
R3 =
Label 17
Text
Tanya
Groupbox 1
Text
Diketahui
Groupbox 2
Text
Ditanyakan
Groupbox 3
Text
Jawab
Numericupdown 1

Menunjukkan R1
Numericupdown 2

Menunjukkan R2
Numericupdown 3

Menunjukkan R3
Numericupdown 4

Menunjukkan I
Numericupdown 5

Menunjukkan V
Combobox 1
Text
Pilih
Textbox 2

Menunjukkan R1
Textbox 3

Menunjukkan R2
Textbox 4

Menunjukkan R3
Textbox 7

Menunjukkan Rs
Textbox 1

Menunjukkan V
Textbox 6

Menunjukkan I
Checkbox 1
Text
Advance (Menunjukkan R1)
Checkbox 2
Text
Advance (Menunjukkan R2)
Checkbox 3
Text
Advance (Menunjukkan R3)
Button 1
Text
Proses
Button 2
Text
Ulangi
Button 3
Text
Kembali ke Menu Awal
Lalu masukkan kode berikut :
Public Class Form3
    Dim a, b, c As Double
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x, a, b, c, q As Double
        a = Val(TextBox2.Text)
        b = Val(TextBox3.Text)
        c = Val(TextBox4.Text)
        q = (Val(TextBox2.Text) + Val(TextBox3.Text) + Val(TextBox4.Text))
        TextBox7.Text = q
        x = (Val(NumericUpDown1.Text) + Val(NumericUpDown2.Text) + Val(NumericUpDown3.Text))
        TextBox5.Text = x
        If ComboBox1.SelectedIndex = 0 Then
            If CheckBox1.Checked = True Or CheckBox2.Checked = True Or CheckBox3.Checked = True Then
                TextBox1.Text = Val(NumericUpDown5.Text) * q
            ElseIf CheckBox1.Checked = False Or CheckBox2.Checked = False Or CheckBox3.Checked = False Then
                TextBox1.Text = Val(NumericUpDown5.Text) * x
            End If
        ElseIf ComboBox1.SelectedIndex = 1 Then
            If CheckBox1.Checked = True Or CheckBox2.Checked = True Or CheckBox3.Checked = True Then
                TextBox6.Text = Val(NumericUpDown4.Text) / q
            ElseIf CheckBox1.Checked = False Or CheckBox2.Checked = False Or CheckBox3.Checked = False Then
                TextBox6.Text = Val(NumericUpDown4.Text) / x
            End If
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        NumericUpDown1.Value = 0
        NumericUpDown2.Value = 0
        NumericUpDown3.Value = 0
        NumericUpDown4.Value = 0
        NumericUpDown5.Value = 0
        TextBox5.Clear()
        TextBox6.Clear()
        TextBox1.Clear()
        TextBox7.Clear()
        ComboBox1.Text = " Pilih "
        NumericUpDown4.Enabled = False
        NumericUpDown5.Enabled = False
        TextBox5.Enabled = False
        TextBox6.Enabled = False
        TextBox1.Enabled = False
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Form2.Show()
        Me.Hide()
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            Form1.Show()
            Me.Hide()
            TextBox2.Show()
            TextBox3.Show()
            TextBox4.Show()
            NumericUpDown1.Hide()
            NumericUpDown2.Hide()
            NumericUpDown3.Hide()
            TextBox7.Show()
            TextBox5.Hide()
            CheckBox2.Enabled = False
            CheckBox3.Enabled = False
        ElseIf CheckBox1.Checked = False Then
            TextBox2.Hide()
            TextBox3.Hide()
            TextBox4.Hide()
            NumericUpDown1.Show()
            NumericUpDown2.Show()
            NumericUpDown3.Show()
            TextBox7.Hide()
            TextBox5.Show()
            CheckBox2.Enabled = True
            CheckBox3.Enabled = True
        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.Checked = True Then
            Form1.Show()
            Me.Hide()
            TextBox2.Show()
            TextBox3.Show()
            TextBox4.Show()
            NumericUpDown1.Hide()
            NumericUpDown2.Hide()
            NumericUpDown3.Hide()
            TextBox7.Show()
            TextBox5.Hide()
            CheckBox1.Enabled = False
            CheckBox3.Enabled = False
        ElseIf CheckBox2.Checked = False Then
            TextBox2.Hide()
            TextBox3.Hide()
            TextBox4.Hide()
            NumericUpDown1.Show()
            NumericUpDown2.Show()
            NumericUpDown3.Show()
            TextBox7.Hide()
            TextBox5.Show()
            CheckBox1.Enabled = True
            CheckBox3.Enabled = True
        End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.Checked = True Then
            Form1.Show()
            Me.Hide()
            TextBox2.Show()
            TextBox3.Show()
            TextBox4.Show()
            NumericUpDown1.Hide()
            NumericUpDown2.Hide()
            NumericUpDown3.Hide()
            TextBox7.Show()
            TextBox5.Hide()
            CheckBox2.Enabled = False
            CheckBox1.Enabled = False
        ElseIf CheckBox3.Checked = False Then
            TextBox2.Hide()
            TextBox3.Hide()
            TextBox4.Hide()
            NumericUpDown1.Show()
            NumericUpDown2.Show()
            NumericUpDown3.Show()
            TextBox7.Hide()
            TextBox5.Show()
            CheckBox2.Enabled = True
            CheckBox1.Enabled = True
        End If
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedIndex = 0 Then
            NumericUpDown5.Enabled = True
            NumericUpDown4.Enabled = False
            TextBox6.Enabled = False
            TextBox5.Enabled = True
            TextBox1.Enabled = True
            Label17.Text = " Rs " + " dan " + " V "
        ElseIf ComboBox1.SelectedIndex = 1 Then
            NumericUpDown5.Enabled = False
            NumericUpDown4.Enabled = True
            TextBox6.Enabled = True
            TextBox5.Enabled = True
            TextBox1.Enabled = False
            Label17.Text = " Rs " + " dan " + " I "
        End If
    End Sub

    Private Sub Form3_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        Me.CenterToScreen()
        NumericUpDown4.Enabled = False
        NumericUpDown5.Enabled = False
        TextBox5.Enabled = False
        TextBox6.Enabled = False
        TextBox1.Enabled = False
    End Sub

    Private Sub Form3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        TextBox2.Hide()
        TextBox3.Hide()
        TextBox4.Hide()
        TextBox7.Hide()
    End Sub

End Class

3. Buat form seperti di bawah ini :































Ubah properties dari komponen tersebut seperti ini :
Obyek
Property
Perubahan
Picturebox 1
Image

Label 3
Text
R1 =
Label 4
Text
R2 =
Label 5
Text
R3 =
Label 1
Text
Tanya
Groupbox 1
Text
Diketahui
Groupbox 2
Text
Ditanyakan
Groupbox 3
Text
Jawab
Numericupdown 1

Menunjukkan R1
Numericupdown 2

Menunjukkan R2
Numericupdown 3

Menunjukkan R3
Numericupdown 4

Menunjukkan I
Numericupdown 5

Menunjukkan V
Combobox 1
Text
Pilih
Textbox 2

Menunjukkan R1
Textbox 3

Menunjukkan R2
Textbox 4

Menunjukkan R3
Textbox 7

Menunjukkan Rs
Textbox 6

Menunjukkan V
Textbox 1

Menunjukkan I
Checkbox 1
Text
Advance (Menunjukkan R1)
Checkbox 2
Text
Advance (Menunjukkan R2)
Checkbox 3
Text
Advance (Menunjukkan R3)
Button 1
Text
Proses
Button 2
Text
Ulangi
Button 3
Text
Kembali ke Menu Awal

Lalu masukkan kode berikut :
Public Class form4
    Dim a, b, c As Double
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim z, a, b, c, w As Double
        a = Val(TextBox2.Text)
        b = Val(TextBox3.Text)
        c = Val(TextBox4.Text)
        w = (Val(TextBox2.Text) * Val(TextBox3.Text) * Val(TextBox4.Text)) / ((Val(TextBox2.Text) * Val(TextBox3.Text)) + (Val(TextBox2.Text) * Val(TextBox4.Text)) + (Val(TextBox3.Text) * Val(TextBox4.Text)))
        TextBox7.Text = w
        z = (Val(NumericUpDown1.Text) * Val(NumericUpDown2.Text) * Val(NumericUpDown3.Text)) / ((Val(NumericUpDown1.Text) * Val(NumericUpDown2.Text)) + (Val(NumericUpDown3.Text) * Val(NumericUpDown2.Text)) + (Val(NumericUpDown1.Text) * Val(NumericUpDown3.Text)))
        TextBox5.Text = z
        If ComboBox1.SelectedIndex = 0 Then
            If CheckBox1.Checked = True Or CheckBox2.Checked = True Or CheckBox3.Checked = True Then
                TextBox6.Text = Val(NumericUpDown4.Text) * w
            ElseIf CheckBox1.Checked = False Or CheckBox2.Checked = False Or CheckBox3.Checked = False Then
                TextBox6.Text = Val(NumericUpDown4.Text) * z
            End If
        ElseIf ComboBox1.SelectedIndex = 1 Then
            If CheckBox1.Checked = True Or CheckBox2.Checked = True Or CheckBox3.Checked = True Then
                TextBox1.Text = Val(NumericUpDown5.Text) / w
            ElseIf CheckBox1.Checked = False Or CheckBox2.Checked = False Or CheckBox3.Checked = False Then
                TextBox1.Text = Val(NumericUpDown5.Text) / z
            End If
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        NumericUpDown1.Value = 0
        NumericUpDown2.Value = 0
        NumericUpDown3.Value = 0
        NumericUpDown4.Value = 0
        NumericUpDown5.Value = 0
        TextBox5.Clear()
        TextBox6.Clear()
        TextBox1.Clear()
        TextBox7.Clear()
        ComboBox1.Text = " Pilih "
        NumericUpDown4.Enabled = False
        NumericUpDown5.Enabled = False
        TextBox5.Enabled = False
        TextBox6.Enabled = False
        TextBox1.Enabled = False
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Form2.Show()
        Me.Hide()
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            Form1.Show()
            Me.Hide()
            TextBox2.Show()
            TextBox3.Show()
            TextBox4.Show()
            NumericUpDown1.Hide()
            NumericUpDown2.Hide()
            NumericUpDown3.Hide()
            TextBox7.Show()
            TextBox5.Hide()
            CheckBox2.Enabled = False
            CheckBox3.Enabled = False
        ElseIf CheckBox1.Checked = False Then
            TextBox2.Hide()
            TextBox3.Hide()
            TextBox4.Hide()
            NumericUpDown1.Show()
            NumericUpDown2.Show()
            NumericUpDown3.Show()
            TextBox7.Hide()
            TextBox5.Show()
            CheckBox2.Enabled = True
            CheckBox3.Enabled = True
        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.Checked = True Then
            Form1.Show()
            Me.Hide()
            TextBox2.Show()
            TextBox3.Show()
            TextBox4.Show()
            NumericUpDown1.Hide()
            NumericUpDown2.Hide()
            NumericUpDown3.Hide()
            TextBox7.Show()
            TextBox5.Hide()
            CheckBox1.Enabled = False
            CheckBox3.Enabled = False
        ElseIf CheckBox2.Checked = False Then
            TextBox2.Hide()
            TextBox3.Hide()
            TextBox4.Hide()
            NumericUpDown1.Show()
            NumericUpDown2.Show()
            NumericUpDown3.Show()
            TextBox7.Hide()
            TextBox5.Show()
            CheckBox1.Enabled = True
            CheckBox3.Enabled = True
        End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.Checked = True Then
            Form1.Show()
            Me.Hide()
            TextBox2.Show()
            TextBox3.Show()
            TextBox4.Show()
            NumericUpDown1.Hide()
            NumericUpDown2.Hide()
            NumericUpDown3.Hide()
            TextBox7.Show()
            TextBox5.Hide()
            CheckBox2.Enabled = False
            CheckBox1.Enabled = False
        ElseIf CheckBox3.Checked = False Then
            TextBox2.Hide()
            TextBox3.Hide()
            TextBox4.Hide()
            NumericUpDown1.Show()
            NumericUpDown2.Show()
            NumericUpDown3.Show()
            TextBox7.Hide()
            TextBox5.Show()
            CheckBox2.Enabled = True
            CheckBox1.Enabled = True
        End If
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedIndex = 0 Then
            NumericUpDown4.Enabled = True
            NumericUpDown5.Enabled = False
            TextBox1.Enabled = False
            TextBox6.Enabled = True
            TextBox5.Enabled = True
            Label1.Text = " Rp " + " dan " + " V "
        ElseIf ComboBox1.SelectedIndex = 1 Then
            NumericUpDown5.Enabled = True
            NumericUpDown4.Enabled = False
            TextBox6.Enabled = False
            TextBox1.Enabled = True
            TextBox5.Enabled = True
            Label1.Text = " Rp " + " dan " + " I "
        End If
    End Sub

    Private Sub form4_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        Me.CenterToScreen()
        NumericUpDown4.Enabled = False
        NumericUpDown5.Enabled = False
        TextBox5.Enabled = False
        TextBox6.Enabled = False
        TextBox1.Enabled = False
    End Sub
End Class

4. Buat form  seperti di bawah ini












Ubah properties dari komponen tersebut seperti ini :
Obyek
Property
Perubahan
Label 1
Text
Penghitungan R        [R=(ρ*l)/A]
Label 2
Text
Hambat Jenis       ( ρ ) :
Label 3
Text
Panjang                ( l ) :
Label 4
Text
Luas Penampang ( A ) :
Label 5
Text
Ω / m ( ohm/meter )
Label 6
Text
m       ( meter )
Label 7
Text
m2     ( m persegi )
Groupbox 1
Text
Keterangan
NumericUpDown 1

Menunjukkan  ( ρ )
NumericUpDown 2

Menunjukkan  ( l )
NumericUpDown 3

Menunjukkan  ( A )
Button 1
Text
OK
Button 2
Text
Clear

Lalu masukkan kode berikut :
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim q As Double
        Me.Hide()
        If NumericUpDown1.Value = 0 Then
            MsgBox("Prosedur salah! Anda belum memasukkan nilai, ulangi penghitungan dari awal.")
            Form2.Show()
        ElseIf NumericUpDown2.Value = 0 Then
            MsgBox("Prosedur salah! Anda belum memasukkan nilai, ulangi penghitungan dari awal.")
            Form2.Show()
        ElseIf NumericUpDown3.Value = 0 Then
            MsgBox("Prosedur salah! Anda belum memasukkan nilai, ulangi penghitungan dari awal.")
            Form2.Show()
        Else
            q = (Val(NumericUpDown1.Text) * Val(NumericUpDown2.Text)) / (Val(NumericUpDown3.Text))
            If form4.CheckBox1.Checked Then
                form4.Show()
                form4.TextBox2.Text = q
            ElseIf form4.CheckBox2.Checked Then
                form4.Show()
                form4.TextBox3.Text = q
            ElseIf form4.CheckBox3.Checked Then
                form4.Show()
                form4.TextBox4.Text = q
            ElseIf Form3.CheckBox1.Checked Then
                Form3.Show()
                Form3.TextBox2.Text = q
            ElseIf Form3.CheckBox2.Checked Then
                Form3.Show()
                Form3.TextBox3.Text = q
            ElseIf Form3.CheckBox3.Checked Then
                Form3.Show()
                Form3.TextBox4.Text = q
            End If
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CenterToScreen()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        NumericUpDown1.Value = 0
        NumericUpDown2.Value = 0
        NumericUpDown3.Value = 0
    End Sub
End Class

Memang sangat panjang programnya tapi itu saya buat untuk memberikan kemudahan bagi penggunanya agar ketika digunakan sang pengguna merasa seperti sedang menjalankan program berbayar yang komersil, karena dalam program ini saya masukkan beberapa kecanggihan kecil. Jadi monggo buat yang pengen mencoba, saya jamin akan rasa puas anda akan terpenuhi, minimal akan geleng-geleng kepala saking banyaknya kodenya. Haha
Kalo masih belum jelas bisa download programnya di sini
Related Posts Plugin for WordPress, Blogger...