07 November 2012

Membuat Kalkulator Dengan Delphi

 






Berikut ini adalah scriptnya:
Button Tambah:
procedure TForm1.Button1Click(Sender: TObject);
var a,b,c : integer; begin
a := strtoint (edit1.Text);
b := strtoint (edit2.Text);
c := a + b;
edit3.Text := inttostr (c);
end; Button Kurang:
procedure TForm1.Button2Click(Sender: TObject);
var a,b,c : integer; begin
a := strtoint (edit1.Text);
b := strtoint (edit2.Text);
c := a - b;
edit3.Text := inttostr (c);
end;
Button Kali
procedure TForm1.Button3Click(Sender: TObject);
var a,b,c : integer; begin
a := strtoint (edit1.Text);
b := strtoint (edit2.Text);
c := a * b;
edit3.Text := inttostr (c);
end;
Button Bagi
procedure TForm1.Button4Click(Sender: TObject);
var a,b,c : double; begin
a := strtofloat (edit1.Text);
b := strtofloat (edit2.Text);
c := a / b;
edit3.Text := floattostr (c);
end;
Button DIV
procedure TForm1.Button5Click(Sender: TObject);
var a,b,c : integer; begin
a := strtoint (edit1.Text);
b := strtoint (edit2.Text);
c := a div b;
edit3.Text := inttostr (c);
end;
Button MOD
procedure TForm1.Button6Click(Sender: TObject);
var a,b,c : integer; begin
a := strtoint (edit1.Text);
b := strtoint (edit2.Text);
c := a mod b;
edit3.Text := inttostr (c);
end;
Button Keluar
procedure TForm1.Button7Click(Sender: TObject);
begin
close; end;

Catatan : Yang diketik hanya tulisan yang miring saja!
Terima kasih dan selamat mencoba :)

27 June 2012

Membuat Program Penjualan Barang


Skrip programnya sebagai berikut :

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Text = "  "
        TextBox2.Text = "  "
        TextBox3.Text = "  "
        TextBox4.Text = "  "
        TextBox5.Text = "  "
        TextBox6.Text = "  "
        TextBox7.Text = "  "
        TextBox8.Text = "  "
        ComboBox1.Items.Add(" Buku Tulis ")
        ComboBox1.Items.Add(" Pencil ")
        ComboBox1.Items.Add(" Majalah ")
        ComboBox1.Items.Add(" Ballpoint ")
        ComboBox1.Items.Add(" Buku Gambar ")
        ComboBox1.Items.Add(" Penghapus ")
        ListBox1.Items.Add(3400)
        ListBox1.Items.Add(2500)
        ListBox1.Items.Add(5000)
        ListBox1.Items.Add(3000)
        ListBox1.Items.Add(4500)
        ListBox1.Items.Add(800)
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = "  "
        TextBox2.Text = "  "
        TextBox3.Text = "  "
        TextBox4.Text = "  "
        TextBox5.Text = "  "
        TextBox6.Text = "  "
        TextBox7.Text = "  "
        TextBox8.Text = "  "
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim nama As String
        Dim alamat As String
        Dim barang As String
        Dim harga As Integer
        Dim jbeli As Integer
        Dim total As Double
        Dim discount As Double
        Dim jmlbayar As Double
        Dim jmluang As Double
        Dim kembali As Double
        nama = TextBox1.Text
        alamat = TextBox2.Text
        jbeli = Val(TextBox3.Text)
        jmluang = Val(TextBox7.Text)
        barang = ComboBox1.Text
        harga = ListBox1.SelectedItem
        total = harga * jbeli
        discount = total * 0.05
        jmlbayar = total - discount
        kembali = jmluang - jmlbayar
        TextBox4.Text = total
        TextBox8.Text = kembali
        TextBox5.Text = discount
        TextBox6.Text = jmlbayar
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Close()
    End Sub
End Class

Semoga bermanfaat dan selamat mencoba.
jangan lupa komentar ya..hehe

sumber : materi kuliah

Membuat Aplikasi Entri Data Pelanggan


Skrip programnya sebagai berikut :


Imports MySql.Data.MySqlClient
Public Class Pelanggan
    Dim kon As New MySqlConnection("server=localhost;User Id=root;database=penjualan")
    Dim perintah As New MySqlCommand
    Dim data As New MySqlDataAdapter
    Dim ds As New DataSet
    Sub tampildata()
        kon.Open()
        perintah.Connection = kon
        perintah.CommandType = CommandType.Text
        perintah.CommandText = "select*from pelanggan"
        data.SelectCommand = perintah
        ds.Tables.Clear()
        data.Fill(ds, "pelanggan")
        DataGridView1.DataSource = ds.Tables("pelanggan")
        kon.Close()
    End Sub
    Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        tampildata()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        kon.Open()
        perintah.Connection = kon
        perintah.CommandType = CommandType.Text
        perintah.CommandText = "insert into pelanggan (kd_plg,nm_plg,alamat) values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "')"
        perintah.ExecuteNonQuery()
        kon.Close()
        MsgBox("data sukses tersimpan", MsgBoxStyle.Information, "pesan")
        tampildata()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        kon.Open()
        perintah.Connection = kon
        perintah.CommandType = CommandType.Text
        perintah.CommandText = "delete from pelanggan where alamat= '" & TextBox3.Text & "'"
        perintah.ExecuteNonQuery()
        kon.Close()
        MsgBox("data telah dihapus", MsgBoxStyle.Information, "informasi")
        tampildata()
    End Sub
    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        Dim i As Integer
        i = DataGridView1.CurrentRow.Index
        With DataGridView1.Rows.Item(i)
            TextBox1.Text = .Cells(0).Value
            TextBox2.Text = .Cells(1).Value
            TextBox3.Text = .Cells(2).Value
        End With
    End Sub
End Clas

Semoga bermanfaat dan selamat mencoba.
kalau ada yang kurang jelas silahkan ditanyakan..
sumber: materi kuliah

14 May 2012

Membuat Program Penjualan Catring

 Lama banget uda gak ada posting lagi kangen juga rasanya untuk memposting lagi..
pada kesempatan kali ini penulis akan memposting bagai mana cara membuat Program Penjualan Catring pada rumah makan dengan aplikasi Visual Basic Net. ketentuannya sebagai berikut..

Kasir itu diinputkan (Nama kasirnya sudah di tentukan dalam program ini)
Pemesan diinputkan
Pilihan menu diinputkan ( menunya dalam program ini : Nasi bungkus, Nasi Kotak & Pramesan)
Harga itu tidak diinputkan
Porsi diinputkan
Jenis pesan diinputkan (didalam program ini jenis pesanya ada 2 : Diantar sama Dijemput)
Biaya pesan, Total Biaya, Discount, sama Total Bayar itu tidak di inputkan..

Syntak untuk Proses ( kilk dua kali pada Button Prosesnya)
        Dim KSR As String
        Dim Pemesan As String
        Dim PM As String
        Dim Harga As Integer
        Dim Porsi As Integer
        Dim JP As String
        Dim BP As Integer
        Dim TBA As Integer
        Dim Dis As Integer
        Dim TBR As Integer

        KSR = ComboBox1.Text
        Pemesan = txtPesanan.Text
        PM = ComboBox2.SelectedItem
        If PM = "Nasi Bungkus" Then
            Harga = 12000
        ElseIf PM = "Nasi Kotak" Then
            Harga = 14000
        Else
            Harga = 20000
        End If
        txtHarga.Text = Harga
        Porsi = Val(txtPorsi.Text)

        JP = ComboBox3.SelectedItem
        If JP = "Diantar" Then
            BP = 0.02 * Porsi * Harga
        Else
            BP = 0
        End If
        txtBP.Text = BP
        TBA = Harga * Porsi + BP
        txtTBA.Text = TBA
        Dis = Val(txtDIS.Text)
        If TBA > 1000000 Then
            Dis = (TBA * 0.05)
        End If
        txtDIS.Text = Dis
        TBR = TBA - Dis
        txtTBR.Text = TBR
Syntak untuk Button Bersih ( klik dua kali pada Button Bersihnya)

        ComboBox1.Text = ""
        txtPesanan.Text = ""
        ComboBox2.Text = ""
        txtHarga.Text = ""
        txtPorsi.Text = ""
        ComboBox3.Text = ""
        txtBP.Text = ""
        txtTBA.Text = ""
        txtDIS.Text = ""
        txtTBR.Text = ""

Syntak untuk Button Keluar (klik dua kali pada Button keluarnya)
Me.Close()

dan dibawah ini adalah tampilannya dari program diatas:
supaya lebih jelas gambarnya diklik saja..

Selamat mencoba semoga bisa bermanfaat..
sumber : materi kuliah.

08 April 2012

Membuat Data Acak Di Pascal

Dibawah ini gan scripnya silahkan dicoba aja ya.hehe


Program contoh;
Uses wincrt;
var
   nil1 : Array [1..100] of integer;
   n,i,j,dum : integer;
Begin
     clrscr;
     write ('Mau berapa isi data acak(integer) ='); readln(n);
     for i := 1 to n do
     begin
          write ('Data Ke ',i, ' : '); readln (nil1[i]);
     end;

     {*penyapuan proses*}
     for i := 1 to n-1 do
     begin
     for j := i to n do
         begin
              if nil1[j] < nil1[i] then
                 begin
                      dum := nil1[j]  ;
                      nil1[j] := nil1[i];
                      nil1[i] := dum;
                 end;
              end;
         end;
         writeln;
         writeln ('Hasil Sortir');
         for i := 1 to n do
             write (nil1[i] : 3);
         readln;
     end.

Dibawah ini Outputnya ok. hehe.



Selamat mencoba semoga bermanfaat.