Diatas adalah contoh from applikasi tersebut dengan
menggunakan aplikasi pemograman vb.net 2008
- buat form seperti tampilan
diatas dengan menggunakan vb.net 2008
- beri nama pada
button,textbox,radiobutton maupun label sesuai dengan nama masing masing
dari button,label,radiobutton dan textbox.
- klik ganda pada form yang tadi
dibuat kemudian masukan kode di bawah ini:
Public Class Form1
Dim ZX1, ZX2, ZX3, Z, a, b, c, y0, d, e, f, simpulan As String
Dim tanda = " + "
Dim dualing(3, 4) As String
Sub hitung()
Dim y1 = "y1", y2 = "y2", y3 = "y3"
If txtZX1.Text <> "" Then
ZX1 = txtZX1.Text & "x1"
Else
ZX1 = ""
End If
If txtZX2.Text <> "" Then
ZX2 = tanda & txtZX2.Text & "x2 "
Else
ZX2 = ""
End If
If txtZX3.Text <> "" Then
ZX3 = tanda & txtZX3.Text & "x3"
Else
ZX3 = ""
End If
If rbtnMax.Checked Then
If cmbtanda1.SelectedItem = ">=" Then
tanda = " - "
If txtAhasil.Text <> "" Then
dualing(0, 3) = tanda + txtAhasil.Text + y1
Else
dualing(0, 3) = ""
End If
If txtAX1.Text <> "" Then
dualing(0, 0) = tanda + txtAX1.Text + y1
Else
dualing(0, 0) = ""
End If
If txtAX2.Text <> "" Then
dualing(0, 1) = tanda + txtAX2.Text + y1
Else
dualing(0, 1) = ""
End If
If txtAX3.Text <> "" Then
dualing(0, 2) = tanda + txtAX3.Text + y1
Else
dualing(0, 2) = ""
End If
Else
tanda = " + "
If txtAhasil.Text <> "" Then
dualing(0, 3) = tanda + txtAhasil.Text + y1
Else
dualing(0, 3) = ""
End If
If txtAX1.Text <> "" Then
dualing(0, 0) = tanda + txtAX1.Text + y1
Else
dualing(0, 0) = ""
End If
If txtAX2.Text <> "" Then
dualing(0, 1) = tanda + txtAX2.Text + y1
Else
dualing(0, 1) = ""
End If
If txtAX3.Text <> "" Then
dualing(0, 2) = tanda + txtAX3.Text + y1
Else
dualing(0, 2) = ""
End If
End If
If cmbtanda2.SelectedItem = ">=" Then
tanda = " - "
If txtBhasil.Text <> "" Then
dualing(1, 3) = tanda + txtBhasil.Text + y2
Else
dualing(1, 3) = ""
End If
If txtBX1.Text <> "" Then
dualing(1, 0) = tanda + txtBX1.Text + y2
Else
dualing(1, 0) = ""
End If
If txtBX2.Text <> "" Then
dualing(1, 1) = tanda + txtBX2.Text + y2
Else
dualing(1, 1) = ""
End If
If txtBX3.Text <> "" Then
dualing(1, 2) = tanda + txtBX3.Text + y2
Else
dualing(1, 2) = ""
End If
Else
tanda = " + "
If txtBhasil.Text <> "" Then
dualing(1, 3) = tanda + txtBhasil.Text + y2
Else
dualing(1, 3) = ""
End If
If txtBX1.Text <> "" Then
dualing(1, 0) = tanda + txtBX1.Text + y2
Else
dualing(1, 0) = ""
End If
If txtBX2.Text <> "" Then
dualing(1, 1) = tanda + txtBX2.Text + y2
Else
dualing(1, 1) = ""
End If
If txtBX3.Text <> "" Then
dualing(1, 2) = tanda + txtBX3.Text + y2
Else
dualing(1, 2) = ""
End If
End If
If cmbtanda3.SelectedItem = ">=" Then
tanda = " - "
If txtChasil.Text <> "" Then
dualing(2, 3) = tanda + txtChasil.Text + y3
Else
dualing(2, 3) = ""
End If
If txtCX1.Text <> "" Then
dualing(2, 0) = tanda + txtCX1.Text + y3
Else
dualing(2, 0) = ""
End If
If txtCX2.Text <> "" Then
dualing(2, 1) = tanda + txtCX2.Text + y3
Else
dualing(2, 1) = ""
End If
If txtCX3.Text <> "" Then
dualing(2, 2) = tanda + txtCX3.Text + y3
Else
dualing(2, 2) = ""
End If
Else
tanda = " + "
If txtChasil.Text <> "" Then
dualing(2, 3) = tanda + txtChasil.Text + y3
Else
dualing(2, 3) = ""
End If
If txtCX1.Text <> "" Then
dualing(2, 0) = tanda + txtCX1.Text + y3
Else
dualing(2, 0) = ""
End If
If txtCX2.Text <> "" Then
dualing(2, 1) = tanda + txtCX2.Text + y3
Else
dualing(2, 1) = ""
End If
If txtCX3.Text <> "" Then
dualing(2, 2) = tanda + txtCX3.Text + y3
Else
dualing(2, 2) = ""
End If
End If
y0 = "Y0 = " & dualing(0, 3) & dualing(1, 3) & dualing(2, 3)
a = "a) " & dualing(0, 0) & dualing(1, 0) & dualing(2, 0) & " >= " & txtZX1.Text
b = "b) " & dualing(0, 1) & dualing(1, 1) & dualing(2, 1) & " >= " & txtZX2.Text
If ZX3 <> "" Then
c = "c) " & dualing(0, 2) & dualing(1, 2) & dualing(2, 2) & " >= " & txtZX3.Text
Else
c = ""
End If
ElseIf rbtnMin.Checked Then
If cmbtanda1.SelectedItem = "<=" Then
tanda = " - "
If txtAhasil.Text <> "" Then
dualing(0, 3) = tanda + txtAhasil.Text + y1
Else
dualing(0, 3) = ""
End If
If txtAX1.Text <> "" Then
dualing(0, 0) = tanda + txtAX1.Text + y1
Else
dualing(0, 0) = ""
End If
If txtAX2.Text <> "" Then
dualing(0, 1) = tanda + txtAX2.Text + y1
Else
dualing(0, 1) = ""
End If
If txtAX3.Text <> "" Then
dualing(0, 2) = tanda + txtAX3.Text + y1
Else
dualing(0, 2) = ""
End If
Else
tanda = " + "
If txtAhasil.Text <> "" Then
dualing(0, 3) = tanda + txtAhasil.Text + y1
Else
dualing(0, 3) = ""
End If
If txtAX1.Text <> "" Then
dualing(0, 0) = tanda + txtAX1.Text + y1
Else
dualing(0, 0) = ""
End If
If txtAX2.Text <> "" Then
dualing(0, 1) = tanda + txtAX2.Text + y1
Else
dualing(0, 1) = ""
End If
If txtAX3.Text <> "" Then
dualing(0, 2) = tanda + txtAX3.Text + y1
Else
dualing(0, 2) = ""
End If
End If
If cmbtanda2.SelectedItem = "<=" Then
tanda = " - "
If txtBhasil.Text <> "" Then
dualing(1, 3) = tanda + txtBhasil.Text + y2
Else
dualing(1, 3) = ""
End If
If txtBX1.Text <> "" Then
dualing(1, 0) = tanda + txtBX1.Text + y2
Else
dualing(1, 0) = ""
End If
If txtBX2.Text <> "" Then
dualing(1, 1) = tanda + txtBX2.Text + y2
Else
dualing(1, 1) = ""
End If
If txtBX3.Text <> "" Then
dualing(1, 2) = tanda + txtBX3.Text + y2
Else
dualing(1, 2) = ""
End If
Else
tanda = " + "
If txtBhasil.Text <> "" Then
dualing(1, 3) = tanda + txtBhasil.Text + y2
Else
dualing(1, 3) = ""
End If
If txtBX1.Text <> "" Then
dualing(1, 0) = tanda + txtBX1.Text + y2
Else
dualing(1, 0) = ""
End If
If txtBX2.Text <> "" Then
dualing(1, 1) = tanda + txtBX2.Text + y2
Else
dualing(1, 1) = ""
End If
If txtBX3.Text <> "" Then
dualing(1, 2) = tanda + txtBX3.Text + y2
Else
dualing(1, 2) = ""
End If
End If
If cmbtanda3.SelectedItem = "<=" Then
tanda = " - "
If txtChasil.Text <> "" Then
dualing(2, 3) = tanda + txtChasil.Text + y3
Else
dualing(2, 3) = ""
End If
If txtCX1.Text <> "" Then
dualing(2, 0) = tanda + txtCX1.Text + y3
Else
dualing(2, 0) = ""
End If
If txtCX2.Text <> "" Then
dualing(2, 1) = tanda + txtCX2.Text + y3
Else
dualing(2, 1) = ""
End If
If txtCX3.Text <> "" Then
dualing(2, 2) = tanda + txtCX3.Text + y3
Else
dualing(2, 2) = ""
End If
Else
tanda = " + "
If txtChasil.Text <> "" Then
dualing(2, 3) = tanda + txtChasil.Text + y3
Else
dualing(2, 3) = ""
End If
If txtCX1.Text <> "" Then
dualing(2, 0) = tanda + txtCX1.Text + y3
Else
dualing(2, 0) = ""
End If
If txtCX2.Text <> "" Then
dualing(2, 1) = tanda + txtCX2.Text + y3
Else
dualing(2, 1) = ""
End If
If txtCX3.Text <> "" Then
dualing(2, 2) = tanda + txtCX3.Text + y3
Else
dualing(2, 2) = ""
End If
End If
y0 = "Y0 = " & dualing(0, 3) & dualing(1, 3) & dualing(2, 3)
a = "a) " & dualing(0, 0) & dualing(1, 0) & dualing(2, 0) & " <= " & txtZX1.Text
b = "b) " & dualing(0, 1) & dualing(1, 1) & dualing(2, 1) & " <= " & txtZX2.Text
If ZX3 <> "" Then
c = "c) " & dualing(0, 2) & dualing(1, 2) & dualing(2, 2) & " <= " & txtZX3.Text
Else
c = ""
End If
End If
If cmbtanda1.SelectedItem = "=" Then
d = ""
Else
d = y1 + ","
End If
If cmbtanda2.SelectedItem = "=" Then
e = ""
Else
e = y2 + ","
End If
If cmbtanda3.SelectedItem = "=" Then
f = ""
Else
f = y3 + ","
End If
If rbtnmax.Checked Then
simpulan = d + e + f + " >= 0"
ElseIf rbtnmin.Checked Then
simpulan = d + e + f + " <= 0"
End If
Z = "Z = " + ZX1 + ZX2 + ZX3
lbhasil.Items.Add(Z)
lbhasil.Items.Add(y0)
lbhasil.Items.Add(a)
lbhasil.Items.Add(b)
lbhasil.Items.Add(c)
lbhasil.Items.Add(simpulan)
End Sub
Private Sub btnHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHitung.Click
lbhasil.Items.Clear()
hitung()
End Sub
End Class