Sabtu, 26 Juni 2010

Simplex Methods To reach Maximum benefits

'Ups image is failed to post
sory for the inconvinience'

or you can dowlnload the full apps build on VB apllication here by Ziddu
Download here

information About the interface:
1. Cb.Text
2. Pr.Text
3. Cb1.Text
4. Pr1.Text
5. Total1.Text
6. Cb2.Text
7. Pr2.Text
8. Total2.Text
9. Cb3.Text
10. Pr3Text
11. Total3.text
12. Command Tabulasi
13. Command Interaksi
14. Command ulang
15. Command keluar
16. Label _z
17. Labelx1
18. Labelx2
19. Label_s1
20. Label_s2
21. Label_s3
22. Label_nk
23. Labelz
24. z1.text
25. x1A.text
26. x2A.text
27. s1A.text
28. s2A.text
29. s3A.text
30. nk1.text
31. labelS1
32. z2.text
33. x1B.text
34. x2B.text
35. s1B.teeext
36. s2B.text
37. s3B.text
38. nk2.text
39. labelS2
40. z3.text
41. x1C.text
42. x2C.text
43. s1C.text
44. s2C.text
45. s3C.text
46. nk3.text
47. labelS3
48. z4.text
49. x1D.text
50. x2D.text
51. s1D.teeext
52. s2D.text
53. s3D.text
54. nk4.text
55. hslcb.text
56. hslpr.text
57. hasilkk.text
58. hasilpivot.text
59. text1.text
60. text2.text
61. text3.text
62. text4.text
63. text5.text
64. text6.text
65. text7.text

Here are the Coding , have try on it

Private Sub interaksi_Click()
On Error GoTo SALAH

'mencari kolom kerja'
'kk1 sampe kk4 sebagai kolom kerja'


If Int(X1A) < kk1 =" X1A"
kk2 =" X1B"
kk3 =" X1C"
kk4 =" X1D"
caption = "CB"
vganti_bp = "CB"
text = "X1"
kk1 =" X2A"
kk2 =" X2B"
kk3 =" X2C"
kk4 =" X2D"
caption = "PR"
vganti_bp = "PR"
text = "X2"
kk2 =" 0"
a =" 0"
a =" NK2"
kk3 =" 0"
b =" 0"
b =" NK3"
kk4 =" 0"
c =" 0"
c =" NK4"> c Then
'
'tak mungkin'



'mencari nilai terkecil dari perbandingan'
'nilai terkecil jadi baris pivot'
'baris pivot baru= baris pivot lama / perpotongan baris pivot dan kolom kerja'
' x=nilai terkecil dari hasil perbandingan'
'P,Q,R,S,T,U,V sebagai hasil dari perhitungan baris pivot baru'
'F sebagai variabel perpotongan baris pivot dan kolom kerja'
'nilai baru= nilai lama-(baris pivot*kolom kerja)'

If A < x =" A"
f =" KK2"
p =" Z2"
q =" X1B"
r =" X2B"
s =" S1B"
t =" S2B"
u =" S3B"
v =" NK2"
text =" P"
text =" Q"
text =" R"
text =" S"
text =" T"
text =" U"
text =" V"
text =" Z1"
text =" X1A"
text =" X2A"
text =" S1A"
text =" S2A"
text =" S3A"
text =" NK1"
text =" Z1"
text =" X1C"
text =" X2C"
text =" S1C"
text =" S2C"
text =" S3C"
text =" NK3"
text =" Z4"
text =" X1D"
text =" X2D"
text =" S1D"
text =" S2D"
text =" S3D"
text =" NK4"
caption =" VGANTI_BP"
text = "S1" a =" c"> C And A > C Then
X = C
F = KK4
'MENCARI BARIS PIVOT
P = Z4 / F
Q = X1D / F
R = X2D / F
S = S1D / F
T = S2D / F
U = S3D / F
V = NK4 / F
'MENCARI NILAI BARU
Z1.Text = Z1 - (kk1 * P)
X1A.Text = X1A - (kk1 * Q)
X2A.Text = X2A - (kk1 * R)
S1A.Text = S1A - (kk1 * S)
S2A.Text = S2A - (kk1 * T)
S3A.Text = S3A - (kk1 * U)
NK1.Text = NK1 - (kk1 * V)
Z2.Text = Z2 - (KK2 * P)
X1B.Text = X1B - (KK2 * Q)
X2B.Text = X2B - (KK2 * R)
S1B.Text = S1B - (KK2 * S)
S2B.Text = S2B - (KK2 * T)
S3B.Text = S3B - (KK2 * U)
NK2.Text = NK2 - (KK2 * V)
Z3.Text = Z1 - (KK3 * P)
X1C.Text = X1C - (KK3 * Q)
X2C.Text = X2C - (KK3 * R)
S1C.Text = S1C - (KK3 * S)
S2C.Text = S2C - (KK3 * T)
S3C.Text = S3C - (KK3 * U)
NK3.Text = NK3 - (KK3 * V)
Z4.Text = P
X1D.Text = Q
X2D.Text = R
S1D.Text = S
S2D.Text = T
S3D.Text = U
NK4.Text = V
LABELS3.Caption = VGANTI_BP
hasilpivot.Text = "S3"

ElseIf A <> C And A < x =" A"
f =" KK2"
p =" Z2"
q =" X1B"
r =" X2B"
s =" S1B"
t =" S2B"
u =" S3B"
v =" NK2"
text =" P"
text =" Q"
text =" R"
text =" S"
text =" T"
text =" U"
text =" V"
text =" Z1"
text =" X1A"
text =" X2A"
text =" S1A"
text =" S2A"
text =" S3A"
text =" NK1"
text =" Z1"
text =" X1C"
text =" X2C"
text =" S1C"
text =" S2C"
text =" S3C"
text =" NK3"
text =" Z4"
text =" X1D"
text =" X2D"
text =" S1D"
text =" S2D"
text =" S3D"
text =" NK4"
caption =" VGANTI_BP"
text = "S1"> c And a = c Then'
'tak mungkin'
'ElseIf a < b =" c"> c Then
'tak mungkin'



ElseIf A < b =" C"
x =" A"
f =" KK2"
p =" Z2"
q =" X1B"
r =" X2B"
s =" S1B"
t =" S2B"
u =" S3B"
v =" NK2"
text =" P"
text =" Q"
text =" R"
text =" S"
text =" T"
text =" U"
text =" V"
text =" Z1"
text =" X1A"
text =" X2A"
text =" S1A"
text =" S2A"
text =" S3A"
text =" NK1"
text =" Z1"
text =" X1C"
text =" X2C"
text =" S1C"
text =" S2C"
text =" S3C"
text =" NK3"
text =" Z4"
text =" X1D"
text =" X2D"
text =" S1D"
text =" S2D"
text =" S3D"
text =" NK4"
caption =" VGANTI_BP"
text = "S1"
b =" c"
a =" c"> B And B <> C Then
X = B
F = KK3
'MENCARI BARIS PIVOT

P = Z3 / F
Q = X1C / F
R = X2C / F
S = S1C / F
T = S2C / F
U = S3C / F
V = NK3 / F
Z3.Text = P
X1C.Text = Q
X2C.Text = R
S1C.Text = S
S2C.Text = T
S3C.Text = U
NK3.Text = V
'MENCARI NILAI BARU
Z1.Text = Z1 - (kk1 * P)
X1A.Text = X1A - (kk1 * Q)
X2A.Text = X2A - (kk1 * R)
S1A.Text = S1A - (kk1 * S)
S2A.Text = S2A - (kk1 * T)
S3A.Text = S3A - (kk1 * U)
NK1.Text = NK1 - (kk1 * V)
Z2.Text = Z2 - (KK2 * P)
X1B.Text = X1B - (KK2 * Q)
X2B.Text = X2B - (KK2 * R)
S1B.Text = S1B - (KK2 * S)
S2B.Text = S2B - (KK2 * T)
S3B.Text = S3B - (KK2 * U)
NK2.Text = NK2 - (KK2 * V)
Z4.Text = Z4 - (KK4 * P)
X1D.Text = X1D - (KK4 * Q)
X2D.Text = X2D - (KK4 * R)
S1D.Text = S1D - (KK4 * S)
S2D.Text = S2D - (KK4 * T)
S3D.Text = S3D - (KK4 * U)
NK4.Text = NK4 - (KK4 * V)
LABELS2.Caption = VGANTI_BP
hasilpivot.Text = "S2"

ElseIf A > B And B < x =" B"
f =" KK3"
p =" Z3"
q =" X1C"
r =" X2C"
s =" S1C"
t =" S2C"
u =" S3C"
v =" NK3"
text =" P"
text =" Q"
text =" R"
text =" S"
text =" T"
text =" U"
text =" V"
text =" Z1"
text =" X1A"
text =" X2A"
text =" S1A"
text =" S2A"
text =" S3A"
text =" NK1"
text =" Z2"
text =" X1B"
text =" X2B"
text =" S1B"
text =" S2B"
text =" S3B"
text =" NK2"
text =" Z4"
text =" X1D"
text =" X2D"
text =" S1D"
text =" S2D"
text =" S3D"
text =" NK4"
caption =" VGANTI_BP"
text = "S2"> B And B < a =" C"
x =" B"
f =" KK3"
p =" Z3"
q =" X1C"
r =" X2C"
s =" S1C"
t =" S2C"
u =" S3C"
v =" NK3"
text =" P"
text =" Q"
text =" R"
text =" S"
text =" T"
text =" U"
text =" V"
text =" Z1"
text =" X1A"
text =" X2A"
text =" S1A"
text =" S2A"
text =" S3A"
text =" NK1"
text =" Z2"
text =" X1B"
text =" X2B"
text =" S1B"
text =" S2B"
text =" S3B"
text =" NK2"
text =" Z4"
text =" X1D"
text =" X2D"
text =" S1D"
text =" S2D"
text =" S3D"
text =" NK4"
caption =" VGANTI_BP"
text = "S2"> B And B > C And A > C Then
X = C
F = KK4

'MENCARI BARIS PIVOT
P = Z4 / F
Q = X1D / F
R = X2D / F
S = S1D / F
T = S2D / F
U = S3D / F
V = NK4 / F
Z4.Text = P
X1D.Text = Q
X2D.Text = R
S1D.Text = S
S2D.Text = T
S3D.Text = U
NK4.Text = V
'MENCARI NILAI BARU
Z1.Text = Z1 - (kk1 * P)
X1A.Text = X1A - (kk1 * Q)
X2A.Text = X2A - (kk1 * R)
S1A.Text = S1A - (kk1 * S)
S2A.Text = S2A - (kk1 * T)
S3A.Text = S3A - (kk1 * U)
NK1.Text = NK1 - (kk1 * V)
Z2.Text = Z2 - (KK2 * P)
X1B.Text = X1B - (KK2 * Q)
X2B.Text = X2B - (KK2 * R)
S1B.Text = S1B - (KK2 * S)
S2B.Text = S2B - (KK2 * T)
S3B.Text = S3B - (KK2 * U)
NK2.Text = NK2 - (KK2 * V)
Z3.Text = Z1 - (KK3 * P)
X1C.Text = X1C - (KK3 * Q)
X2C.Text = X2C - (KK3 * R)
S1C.Text = S1C - (KK3 * S)
S2C.Text = S2C - (KK3 * T)
S3C.Text = S3C - (KK3 * U)
NK3.Text = NK3 - (KK3 * V)

LABELS3.Caption = VGANTI_BP
hasilpivot.Text = "S3"



'ElseIf a > b And b > c And a <> b And b > c And a = c Then
'tak mungkin'
'ElseIf a > b And b = c And a > c Then
'tak mungkin'
'ElseIf a > b And b = c And a <> b And b = c And a = c Then
'tak mungkin'
'ElseIf a = b And b <> c Then
'tak mungkin'
'ElseIf a = b And b < a =" b" a =" c" a =" B"> C And A > C Then
X = C
F = KK4
'MENCARI BARIS PIVOT

P = Z4 / F
Q = X1D / F
R = X2D / F
S = S1D / F
T = S2D / F
U = S3D / F
V = NK4 / F
Z4.Text = P
X1D.Text = Q
X2D.Text = R
S1D.Text = S
S2D.Text = T
S3D.Text = U
NK4.Text = V

'MENCARI NILAI BARU
Z1.Text = Z1 - (kk1 * P)
X1A.Text = X1A - (kk1 * Q)
X2A.Text = X2A - (kk1 * R)
S1A.Text = S1A - (kk1 * S)
S2A.Text = S2A - (kk1 * T)
S3A.Text = S3A - (kk1 * U)
NK1.Text = NKZ2.Text = Z2 - (KK2 * P)
X1B.Text = X1B - (KK2 * Q)
X2B.Text = X2B - (KK2 * R)
S1B.Text = S1B - (KK2 * S)
S2B.Text = S2B - (KK2 * T)
S3B.Text = S3B - (KK2 * U)
NK2.Text = NK2 - (KK2 * V)
Z3.Text = Z1 - (KK3 * P)
X1C.Text = X1C - (KK3 * Q)
X2C.Text = X2C - (KK3 * R)
S1C.Text = S1C - (KK3 * S)
S2C.Text = S2C - (KK3 * T)
S3C.Text = S3C - (KK3 * U)
NK3.Text = NK3 - (KK3 * V)

LABELS3.Caption = VGANTI_BP
hasilpivot.Text = "S3"



'ElseIf a = b And b > c And a < a =" b"> c And a = c Then
'tak mungkin'
'ElseIf a = b And b = c And a > c Then
'tak mungkin'
'ElseIf a = b And b = c And a < a =" b" b =" c" a =" c">





End If


End If
Text1.Text = P
Text2.Text = Q
Text3.Text = R
Text4.Text = S
Text5.Text = T
Text6.Text = U
Text7.Text = V

If Labels1.Caption = "CB" Then
HSLCB.Text = NK2
End If
If LABELS2.Caption = "CB" Then
HSLCB.Text = NK3
End If
If LABELS3.Caption = "CB" Then
HSLCB.Text = NK4
End If

If Labels1.Caption = "PR" Then
HSLPR.Text = NK2
End If
If LABELS2.Caption = "PR" Then
HSLPR.Text = NK3
End If
If LABELS3.Caption = "PR" Then
HSLPR.Text = NK4
End If

Exit Sub
SALAH:
MsgBox "KLIK TABULASI DULU", vbInformation

End Sub




Private Sub tabulasi_Click()
On Error GoTo SALAH
Z1.Text = 1
Z2.Text = 0
Z3.Text = 0
Z4.Text = 0
X1A.Text = (CB * -1)
X1B.Text = CB1
X1C.Text = CB2
X1D.Text = CB3
X2A.Text = (PR * -1)
X2B.Text = PR1
X2C.Text = PR2
X2D.Text = PR3
S1A.Text = 0
S1B.Text = 1
S1C.Text = 0
S1D.Text = 0
S2A.Text = 0
S2B.Text = 0
S2C.Text = 1
S2D.Text = 0
S3A.Text = 0
S3B.Text = 0
S3C.Text = 0
S3D.Text = 1
NK1.Text = 0
NK2.Text = TOTAL1
NK3.Text = TOTAL2
NK4.Text = TOTAL3
Exit Sub
SALAH:
MsgBox "ISI DULU YANG KOSONG", vbInformation
CB.SetFocus

End Sub


Private Sub KELUAR_Click()
Dim KELUAR As String
Dim PESAN As String
PESAN = MsgBox("APAKAH YAKIN AKAN KELUAR?", vbOKCancel + vbQuestion, "PASTIKAN")
If PESAN = vbOK Then Unload Me
If PESAN = vbCancel Then CB.SetFocus
End Sub





Private Sub ULANG_Click()
CB.Text = ""
PR.Text = ""
CB1.Text = ""
CB2.Text = ""
CB3.Text = ""
PR1.Text = ""
PR2.Text = ""
PR3.Text = ""
TOTAL1.Text = ""
TOTAL2.Text = ""
TOTAL3.Text = ""

Z1.Text = ""
Z2.Text = ""
Z3.Text = ""
Z4.Text = ""
X1A.Text = ""
X1B.Text = ""
X1C.Text = ""
X1D.Text = ""
X2A.Text = ""
X2B.Text = ""
X2C.Text = ""
X2D.Text = ""
S1A.Text = ""
S1B.Text = ""
S1C.Text = ""
S1D.Text = ""
S2A.Text = ""
S2B.Text = ""
S2C.Text = ""
S2D.Text = ""
S3A.Text = ""
S3B.Text = ""
S3C.Text = ""
S3D.Text = ""
NK1.Text = ""
NK2.Text = ""
NK3.Text = ""
NK4.Text = ""
HSLCB.Text = ""
HSLPR.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""



End Sub

Senin, 29 Maret 2010



MEMBUAT LUAS BANGUN
Menghitung Luas Persegi panjang :
Panjang :

1.Input panjang : Textbox > Text (kosongkan isinya  edit di caption) > name : txtpj
2.Input panjang : Textbox > Text (kosongkan isinya  edit di caption) > name : txtpj
3.Command Button > name : cmdluas> caption Hitung Luas
4.Input luas : Textbox > Text (kosongkan isinya  edit di caption) > name : txtluas
5.Double click command button :

Private Sub Command1_Click()
Text3.Text = Text2.Text * Text1.Text
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End Sub


Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub
Tool tip text

Visual Basic




VISUAL BASIC

  • Memindah teks :

  1. Textbox Text (kosongkan) name : txtnama

  2. Command Button name : cmdpindah caption pindah

  3. Textbox Text (kosongkan isinya) name : txtpindah

  4. Double click tombol pindah, isikan :


Private Sub cmdpindah_Click()

txtpindah.Text = txtnama.Text

txtnama.Text = " "

End Sub


  1. Klik Start


Tampilan :











  • MEMBUAT LUAS BANGUN

Menghitung Luas Persegi panjang :



Panjang :


  1. Input panjang : Textbox > Text (kosongkan isinya edit di caption) > name : txtpj

  2. Input panjang : Textbox > Text (kosongkan isinya edit di caption) > name : txtpj

  3. Command Button > name : cmdluas> caption Hitung Luas

  4. Input luas : Textbox > Text (kosongkan isinya edit di caption) > name : txtluas

  5. Double click command button :


Private Sub Command1_Click()

Text3.Text = Text2.Text * Text1.Text

End Sub


Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.SetFocus

End Sub



Private Sub Command3_Click()

Unload Me

End Sub


Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Text2.SetFocus

End If

End Sub


Private Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Command1.SetFocus

End If

End Sub

Tool tip text

Text2

Text1

Command1

Command2

Command3

Text2





Program menghitung luas

Terdiri dari

variable yang berupa label antara lain

  1. panjang sebagai keterangan text box yang berisi angka yang menunjukan panjang dari sebuah persegi panjang yang akan dihitung.

  2. lebar sebagai keterangan sebagai keterangan text box yang berisi angka yang menunjukan lebar dari sebuah persegi panjang yang akan dihitung.


yang berupa text box. Antara lain

  1. text1.text yang berupa kolom isian yang berisi besaran panjang persegi panjang yang akan dihitung.

  2. text2.text yang berupa kolom isian yang berisi besaran panjang persegi panjang yang akan dihitung.

  3. text3.text kolom isian yang berisi besaran luas persegi panjang yang akan dihitung. Dengan mengalikan antara nilai yang terdapat pada text1.txt dengan text2.txt

yang berupa command button antara lain

    • Tombol hasil yakni sebuah tombol yang akan memproses perhitungan yang berupa nilai yang ada pada text1.text dengan text2.txt dan hasilnya akan muncul pada text3.text


Private Sub Command1_Click()

Text3.Text = Text2.Text * Text1.Text

End Sub



    • Tombol ulang dengan namelabel “command 2”

jika “ulang” diklik maka nilai pada variable text1,text2 dan text3 akan kembali kosong tak bernilaidan kemudian kursor akan secara otomatis berada pada kolom text1 untuk pengisian kembali nilai baru yang akan dihitung


Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.SetFocus

End Sub


    • Tombol exit dengan name label “command3

jika “exit” diklik maka program akan keluar secara otomatis


Private Sub Command3_Click()

Unload Me

End Sub



Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Text2.SetFocus

End If

End Sub

Ket. Jika text1 di enter maka kursor akan beralih ke text2



Private Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Command1.SetFocus

End If

End Sub

Ket. Jika text2 di enter maka kursor akan beralih ke hasil






  • LUAS PERSEGI PANJANG & SEGITIGA (HASIL 1 BOX)








Panjang1.Text

Lebar1.Text

Alas.Text

Tinggi.Text

Hasil.Text






(Button, Caption : Luas Persegi Panjang , Name : HITUNG)

Private Sub HITUNG_Click()

On Error GoTo salah


Call BALIK

hasil.Text = panjang1.Text * lebar1.Text

Exit Sub

salah:

MsgBox "PANJANG DAN LEBAR BELUM DIISI!!"

End Sub

Sub BALIK()

panjang1.SetFocus

End Sub


(Button, Caption : Luas Segitiga , Name : OK)

Private Sub ok_Click()

On Error GoTo salah


Call BALIK1

hasil.Text = alas.Text * tinggi.Text / 2

Exit Sub

salah:

MsgBox "ALAS DAN TINGGI BELUM DIISI!!"

End Sub


Sub BALIK1()

alas.SetFocus

End Sub


(Button, Caption : Selesai , Name : SELESAI)

Private Sub SELESAI_Click(Index As Integer)

End

End Sub




























CATATAN :

  • Huruf bergaris miring merupakan fungsi message box.

  • Huruf tebal merupakan fungsi utama penghitungan.































    • PROGRAM MENCARI BILANGAN GENAP DAN GANJIL










Text1.Text

Label1.Caption




Command1




Command2


Command3



(Button, Caption : PROSES , Name : Command1)

Private Sub Command1_Click()

If Val(Text1.Text) Mod 2 = 0 Then

Label1.Caption = "genap"

Else

Label1.Caption = "ganjil"

End If

Command2.Enabled = True

Command1.Enabled = False

End Sub


(Button, Caption : COBA LAGI , Name : Command2)

Private Sub Command2_Click()

Text1.Text = ""

Label1.Caption = ""

Text1.SetFocus

Command1.Enabled = True

Command2.Enabled = False

End Sub


(Button, Caption : KELUAR , Name : Command3)

Private Sub Command3_Click()

End

End Sub






























CATATAN : Huruf miring merupakan fungsi untuk mengaktifkan tombol coba lagi setelah tombol proses ditekan





Keterangan

Private Sub Command1_Click()

If Val(Text1.Text) Mod 2 = 0 Then

Label1.Caption = "genap"

Else

Label1.Caption = "ganjil"

End If

Command2.Enabled = True

Command1.Enabled = False

End Sub













Pada awal permulaan program berjalan jika command2 atau proses diklik maka program akan berjalan dengan membagi jika nilai pada text 1 dibagi dengan 2 tak ada sisa maka pada label 1 caption bernilai genap.

Jika terdapat sisa akan bernilai ganjil. Kemudian setelah hasil didapat tombol proses tak berfungsi lagi dan tombol cobalagi akan berfungsi


(Button, Caption : COBA LAGI , Name : Command2)

Private Sub Command2_Click()

Text1.Text = ""

Label1.Caption = ""

Text1.SetFocus

Command1.Enabled = True

Command2.Enabled = False

End Sub













Jika tombol coba lagi di klik maka text1 dan label1 akan bernilai kosong dan kusrsor akan berada pada text1 dan kemudian tombol coba lagi tak berfungsi sedang tombol proses akan berfungsi kembali



Private Sub Command3_Click()

end

End Sub


    • Tombol exit dengan name label “command3

jika “exit” diklik maka program akan keluar secara otomatis








  • PROGRAM MENCARI BILANGAN PRIMA DAN BUKAN PRIMA









Text1.Text

Text2.Caption

Command1

Command2


Command3






(Button, Caption : PROSES , Name : Command1)

Private Sub Command1_Click()

If Val(Text1.Text) = 1 Then

text2.Caption = "Bukan Prima"

ElseIf Val(Text1.Text) = 2 Then

text2.Caption = "Prima"

Else

For i = 2 To Val(Text1.Text) – 1

If Val(Text1.Text) Mod i = 0 Then

text2.Caption = "Bukan Prima"

Exit For

Else

text2.Caption = "Prima"

End If

Next

End If

Command2.Enabled = True

Command1.Enabled = False

End Sub

(Button, Caption : ULANG , Name : Command2)

Private Sub Command2_Click()

Text1.Text = ""

text2.Caption = ""

Text1.SetFocus

Command1.Enabled = True

Command2.Enabled = False

End Sub

(Button, Caption : EXIT , Name : Command3)

Private Sub Command3_Click()

End

End Sub


































CATATAN : SetFocus untuk mengarahkan kursor ke textbox.

(Button, Caption : PROSES , Name : Command1)

Private Sub Command1_Click()

If Val(Text1.Text) = 1 Then

text2.Caption = "Bukan Prima"

ElseIf Val(Text1.Text) = 2 Then

text2.Caption = "Prima"

Else

For i = 2 To Val(Text1.Text) – 1

If Val(Text1.Text) Mod i = 0 Then

text2.Caption = "Bukan Prima"

Exit For

Else

text2.Caption = "Prima"

End If

Next

End If

Command2.Enabled = True

Command1.Enabled = False

End Sub
























Jika tombol proses diklik maka akan mencocokan nilai yang ada pada text.1 jika nilainya sama dengan 1 maka text2.caption akan bernilai “bukan prima” dan kemudian jika nilai yang ada pada text1 bernilai 2 maka text2.caption akan bernilai “prima”

Jika pada text1 nilainya bukan angka 1 dan angka 2 maka program akan berjalan menuju baris setelah “else”

Untuk nilai bilangan i = 2 sampai nilai text1 dikurangi 1 lakukan perintah jika nilai text1 dibagi bilangan I sisanya samadengan 0 maka text2.caption bernilai bukan prima. Kemudian perintah for nya selesai. Lalu tombol ulang berfungsi dan tombol proses tidak berfungsi.

(Button, Caption : ULANG , Name : Command2)

Private Sub Command2_Click()

Text1.Text = ""

text2.Caption = ""

Text1.SetFocus

Command1.Enabled = True

Command2.Enabled = False

End Sub














Jika tombol tombol ulang di klik maka text1 dan text2 caption akan bernilai kosong dan kusrsor akan berada pada text1 dan kemudian tombol ulang tak berfungsi sedang tombol proses akan berfungsi kembali .



Private Sub Command3_Click()

end

End Sub


    • Tombol exit dengan name label “command3

jika “exit” diklik maka program akan keluar secara otomatis




  • PROGRAM MENCARI BILANGAN GENAP & GANJIL (MODIFIKASI)













Bil(0).Text

Bil(1).Text

Bil(2).Text

Bil(3).Text

Bil(4).Text

Txtganjil.Text

Txt_genap.Text













]

(Button, Caption : ULANG , Name : Coba Lagi2)

Private Sub cobalagi_Click()

bil(0).Text = ""

bil(0).BackColor = vbWhite

bil(1).Text = ""

bil(1).BackColor = vbWhite

bil(2).Text = ""

bil(2).BackColor = vbWhite

bil(3).Text = ""

bil(3).BackColor = vbWhite

bil(4).Text = ""

bil(4).BackColor = vbWhite

txtganjil.Text = ""

txt_genap.Text = ""

bil(0).SetFocus

End Sub


(Button, Caption : GANJIL , Name : Command2)

Private Sub Command2_Click()

For i = 0 To 4

ganjil = bil(i) / 2 - Int(bil(i) / 2)

If ganjil <> 0 Then

bil(i).BackColor = vbYellow

txtganjil.Text = txtganjil.Text & " " & Str(bil(i))

End If

Next


Command3.Enabled = True

Command2.Enabled = False

End Sub



(Button, Caption : GENAP , Name : Command3)

Private Sub Command3_Click()

For i = 0 To 4

genap = bil(i) / 2 - Int(bil(i) / 2)

If genap = 0 Then

bil(i).BackColor = vbBlue

txt_genap.Text = txt_genap.Text & " " & Str(bil(i))

End If

Next


Command2.Enabled = False

Command3.Enabled = False

End Sub


(Button, Caption : KELUAR , Name : Command1)

Private Sub Command1_Click()

End

End Sub



















































(Button, Caption : ULANG , Name : Coba Lagi2)

Private Sub cobalagi_Click()

bil(0).Text = ""

bil(0).BackColor = vbWhite

bil(1).Text = ""

bil(1).BackColor = vbWhite

bil(2).Text = ""

bil(2).BackColor = vbWhite

bil(3).Text = ""

bil(3).BackColor = vbWhite

bil(4).Text = ""

bil(4).BackColor = vbWhite

txtganjil.Text = ""

txt_genap.Text = ""

bil(0).SetFocus

End Sub

















Jika bil tak bernilai mulai dari bil 0 sampai dengan 4 maka warna backgroundnya akan putih dan txtganji dan txtgenap akan kosong.

(Button, Caption : GANJIL , Name : Command2)

Private Sub Command2_Click()

For i = 0 To 4

ganjil = bil(i) / 2 - Int(bil(i) / 2)

If ganjil <> 0 Then

bil(i).BackColor = vbYellow

txtganjil.Text = txtganjil.Text & " " & Str(bil(i))

End If

Next


Command3.Enabled = True

Command2.Enabled = False

End Sub

















Untuk i samadengan 0 sampai dengan 4.

Ganjil sama dengan bil dibagi 2 dikurangi pembulatan bilangan ke i dibagi 2 jika nilai ganjil tidak sama dengan 0 kemudian warna bil ke i sama dengan kuning

Dan txt.gantjil bernilai angka hasil perhitungan secara berulang. Kemudian ganjil tak berfungsi dan genap berfungsi.








(Button, Caption : GENAP , Name : Command3)

Private Sub Command3_Click()

For i = 0 To 4

genap = bil(i) / 2 - Int(bil(i) / 2)

If genap = 0 Then

bil(i).BackColor = vbBlue

txt_genap.Text = txt_genap.Text & " " & Str(bil(i))

End If

Next


Command2.Enabled = False

Command3.Enabled = False

End Sub















genapGanjil sama dengan bil dibagi 2 dikurangi pembulatan bilangan ke i dibagi 2 jika nilai genap sama dengan 0 kemudian warna bil ke i sama dengan biru

Dan txt.genap bernilai angka hasil perhitungan secara berulang. Kemudian genap tak berfungsi dan ganjil berfungsi.



Private Sub Command3_Click()

end

End Sub


    • Tombol keluar dengan name label “command1

jika “keluar” diklik maka program akan keluar secara otomatis



















  • PROGRAM MENCARI BILANGAN FAKTORIAL











(Button, Caption : PROSES Name : cmdproses)

Private Sub cmd Proses_Click()

bil = 1

For i = 1 To txtangka.Text

bil = bil * i

Next

txthasil.Text = Str(bil)

Command1.Enabled = True

cmdproses.Enabled = False

End Sub


(Button, Caption : lagi , Name : command1)

Private Sub Command1_Click()

txtangka.Text = ""

txthasil.Text = ""

txtangka.SetFocus

Command1.Enabled = False

cmdproses.Enabled = True

End Sub

Private Sub Command2_Click()

End

End Sub

















(Button, Caption : PROSES Name : cmdproses)

Private Sub cmd Proses_Click()

bil = 1

For i = 1 To txtangka.Text

bil = bil * i

Next

txthasil.Text = Str(bil)

Command1.Enabled = True

cmdproses.Enabled = False

End Sub








Keterangan:

Jika proses diklik maka bil akan bernilai 1 , kemudian untuk i bernilai 1 sampai dengan nilai yang terdapat pada txtangka bil akan bernilai mulai dari perkalian bil dengan i dan nilai bil kemudian dikalikan dengan pertambahan nilai i sampai dengan nilai txtangka. Kemudian nilai bil akan ditampilkan pada txthasil lalu tombol proses tidak akan berfungsi dan tombol lagi akan berfungsi.


(Button, Caption : lagi , Name : command1)

Private Sub Command1_Click()

txtangka.Text = ""

txthasil.Text = ""

txtangka.SetFocus

Command1.Enabled = False

cmdproses.Enabled = True

End Sub














Jika tombol “lagi” maka txt angka dan txt hasil akan bernilai kosongdan tuoso akan berada pada txtangka.


Private Sub Command3_Click()

end

End Sub


    • Tombol exit dengan name label “command2

jika “exit” diklik maka program akan keluar secara otomatis