Wednesday, 11 December 2013

C++ Menggunakan Struct Menampilkan Nilai


#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
struct nilai
{
int siswa_ke;
char nama[20];
int mid;
int final;
int rata;
};
nilai mhs[10];
for(int i = 0; i <3; i++)
{
 mhs[i].siswa_ke=i+1;
 cout<<"Nama: ";
 cin>>mhs[i].nama;
 cout<<"Input Nilai Mid : ";
 cin>>mhs[i].mid;
 cout<<"Input Nilai Final : ";
 cin>>mhs[i].final;
 mhs[i].rata=(mhs[i].mid+mhs[i].final)/2;
}
 cout<<"---------------------------------------------------------"<<endl;
 cout<<"Siswa Ke  NAMA  MID  FINAL  RATA-RATA"<<endl;
 cout<<"---------------------------------------------------------"<<endl;
for(int i = 0; i <3; i++)
{
 cout<<mhs[i].siswa_ke<<"         ";
 cout<<mhs[i].nama<<"   ";
 cout<<mhs[i].mid<<"     ";
 cout<<mhs[i].final<<"      ";
 cout<<mhs[i].rata<<endl;
}
 cout<<"---------------------------------------------------------";
getch();
}

Monday, 9 December 2013

Program Penjualan Pulsa Visual Basic





Private Sub n_otomatis()
If Not Text1 = "" Then
faktur = Mid(Text1.Text, 1, 5)
NoUrut = CLng(faktur)
NoUrut = NoUrut + 1
Text1.Text = "0" + Format(NoUrut, "0000")
Else
NoUrut = 1
Text1.Text = "0" + Format(NoUrut, "0000")
End If
End Sub

Private Sub Combo2_Click()
If Combo2.Text = "5000" Then
Text2.Text = "6000"
ElseIf Combo2.Text = "10000" Then
Text2.Text = "12000"
ElseIf Combo2.Text = "50000" Then
Text2.Text = "51000"
Else
Text2.Text = "102000"
End If
Text6.Text = Val(Text3.Text) - Val(Combo2.Text)
End Sub

Private Sub Command1_Click()
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields!No_Faktur = Text1.Text
Adodc1.Recordset.Fields!Tanggal = Label1.Caption
Adodc1.Recordset.Fields!Waktu = Label2.Caption
Adodc1.Recordset.Fields!Operator = Combo1.Text
Adodc1.Recordset.Fields!Nominal = Combo2.Text
Adodc1.Recordset.Fields!Harga = Text2.Text
Adodc1.Recordset.Fields!Saldo = Text3.Text
Adodc1.Recordset.Fields!Uang_Bayar = Text4.Text
Adodc1.Recordset.Fields!Kembalian = Text5.Text
Adodc1.Recordset.Fields!Sisa_Saldo = Text6.Text
Adodc1.Recordset.Fields!No_Tujuan = Text7.Text
If Text6.Text <> Empty Then
Text3 = Text6.Text
End If
Adodc1.Recordset.Update
MsgBox "Data Telah Tersimpan", vbInformation
n_otomatis
Combo1.Text = ""
Combo2.Text = ""
Text2.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
End Sub

Private Sub Command2_Click()
Combo1.Text = ""
Combo2.Text = ""
Text2.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
MsgBox "Data Dibatalkan", vbInformation
End Sub

Private Sub Command3_Click()
Adodc1.Recordset.Fields!No_Faktur = Text1.Text
Adodc1.Recordset.Fields!Tanggal = Label1.Caption
Adodc1.Recordset.Fields!Waktu = Label2.Caption
Adodc1.Recordset.Fields!Operator = Combo1.Text
Adodc1.Recordset.Fields!Nominal = Combo2.Text
Adodc1.Recordset.Fields!Harga = Text2.Text
Adodc1.Recordset.Fields!Saldo = Text3.Text
Adodc1.Recordset.Fields!Uang_Bayar = Text4.Text
Adodc1.Recordset.Fields!Kembalian = Text5.Text
Adodc1.Recordset.Fields!Sisa_Saldo = Text6.Text
Adodc1.Recordset.Fields!No_Tujuan = Text7.Text
Adodc1.Recordset.Update
MsgBox "Data Berhasil Diedit", vbInformation
End Sub

Private Sub Command4_Click()
Adodc1.Recordset.Delete
MsgBox "Data Berhasil Dihapus", vbInformation
End Sub

Private Sub Command5_Click()
Unload Me
MsgBox "Berhasil Keluar", vbInformation
End Sub

Private Sub DataGrid1_Click()
Text1.Text = Adodc1.Recordset.Fields!No_Faktur
Label1.Caption = Adodc1.Recordset.Fields!Tanggal
Label2.Caption = Adodc1.Recordset.Fields!Waktu
Combo1.Text = Adodc1.Recordset.Fields!Operator
Combo2.Text = Adodc1.Recordset.Fields!Nominal
Text2.Text = Adodc1.Recordset.Fields!Harga
Text3.Text = Adodc1.Recordset.Fields!Saldo
Text4.Text = Adodc1.Recordset.Fields!Uang_Bayar
Text5.Text = Adodc1.Recordset.Fields!Kembalian
Text6.Text = Adodc1.Recordset.Fields!Sisa_Saldo
Text7.Text = Adodc1.Recordset.Fields!No_Tujuan
End Sub

Private Sub Form_Load()
Combo1.AddItem "Telkomsel"
Combo1.AddItem "XL"
Combo1.AddItem "Indosat"
Combo1.AddItem "SmartFren"
Combo1.AddItem "Axis"
Combo2.AddItem "5000"
Combo2.AddItem "10000"
Combo2.AddItem "50000"
Combo2.AddItem "100000"
Text3 = 5000000
n_otomatis
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
End Sub

Private Sub Text4_Change()
Text5.Text = Val(Text4.Text) - Val(Text2.Text)
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Date
End Sub

Private Sub Timer2_Timer()
Label2.Caption = Time
End Sub