• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

VBA Form ile kayıt

  • Konbuyu başlatan Konbuyu başlatan oaltin
  • Başlangıç tarihi Başlangıç tarihi
Katılım
31 Ocak 2011
Mesajlar
10
Excel Vers. ve Dili
Excell 2003
Merhaba arkadaşlar
VBA konusunda çok fazla bilgim yok.Kendimce kitaplar yardımıyla birşeyler yapmaya çalışıyorum.Kitap yardımıyla yaptığım bu form (KayitAdi='C:\Desktop\DELPHİ\DENEME') bu dosyaya herhangi bir kayıt yapmıyor.Girdiğim bilgileri kaydetmesi gerektiğini düşünüyorum.Bilgisi olan paylaşırsa sevinirim.TEŞEKKÜRLER.

unit PERSONEL;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit1: TEdit;
ListBox1: TListBox;
ListBox2: TListBox;
ListBox3: TListBox;
ListBox4: TListBox;
ListBox5: TListBox;
ListBox6: TListBox;
ListBox7: TListBox;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;

procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);





private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
A:integer;
KayitAdi:String;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
KayitAdi:=InputBox('DOSYA KAYDI','Kayıt Yapılacak Dizini Giriniz','C:\Desktop\DELPHİ\DENEME');
if not (KayitAdi='C:\Desktop\DELPHİ\DENEME') then
begin
if DirectoryExists(KayitAdi) then
begin
A:=Application.MessageBox('Aynı Kayıt Zaten Var Üzerine Yazılsınmı?',
'DİKKAT',mb_YesNo+mb_IconQuestion);
end
else
begin
ChDir('C:\');
ForceDirectories(KayitAdi);
A:=6;
end;
if A=6 then
begin
ListBox1.Items.SaveToFile(KayitAdi+'\Proje1A');
ListBox2.Items.SaveToFile(KayitAdi+'\Proje1B');
ListBox3.Items.SaveToFile(KayitAdi+'\Proje1C');
ListBox4.Items.SaveToFile(KayitAdi+'\Proje1D');
ListBox5.Items.SaveToFile(KayitAdi+'\Proje1E');
ListBox6.Items.SaveToFile(KayitAdi+'\Proje1F');
ListBox7.Items.SaveToFile(KayitAdi+'\Proje1G');
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
KayitAdi:=InputBox('DOSYA AÇ','Açılacak Kayıt Adını Giriniz',
'C:\Desktop\DELPHİ\DENEME');
if not (KayitAdi='C:\Desktop\DELPHİ\DENEME') then
begin
if FileExists(KayitAdi+'\Proje1A') then
begin
ListBox1.Items.LoadFromFile(KayitAdi+'\Proje1A');
ListBox2.Items.LoadFromFile(KayitAdi+'\Proje1B');
ListBox3.Items.LoadFromFile(KayitAdi+'\Proje1C');
ListBox4.Items.LoadFromFile(KayitAdi+'\Proje1D');
ListBox5.Items.LoadFromFile(KayitAdi+'\Proje1E');
ListBox6.Items.LoadFromFile(KayitAdi+'\Proje1F');
ListBox7.Items.LoadFromFile(KayitAdi+'\Proje1G');
end
else
ShowMessage('Kayıtlı Dosya Bulunamadı!');
end;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
A:=ListBox1.ItemIndex;
ListBox2.ItemIndex:=A;
ListBox3.ItemIndex:=A;
ListBox4.ItemIndex:=A;
ListBox5.ItemIndex:=A;
ListBox6.ItemIndex:=A;
ListBox7.ItemIndex:=A;

ListBox2.TopIndex:=ListBox1.TopIndex;
ListBox3.TopIndex:=ListBox1.TopIndex;
ListBox4.TopIndex:=ListBox1.TopIndex;
ListBox5.TopIndex:=ListBox1.TopIndex;
ListBox6.TopIndex:=ListBox1.TopIndex;
ListBox7.TopIndex:=ListBox1.TopIndex;

Edit1.Text:=ListBox1.Items[A];
Edit2.Text:=ListBox2.Items[A];
Edit3.Text:=ListBox3.Items[A];
Edit4.Text:=ListBox4.Items[A];
Edit5.Text:=ListBox5.Items[A];
Edit6.Text:=ListBox6.Items[A];
Edit7.Text:=ListBox7.Items[A];
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if Edit1.Text=''then ShowMessage('İsim Bilgileri Eksik')
else
begin
if (ListBox1.Items.IndexOf(Edit1.Text)>-1) and
(ListBox3.Items.IndexOf(Edit3.Text)>-1) then
ShowMessage('Aynı İsim ve Tel.Sahip Kayıt Mevcuttur.')
else
begin
ListBox1.Items.Add(Edit1.Text);
ListBox2.Items.Add(Edit2.Text);
ListBox3.Items.Add(Edit3.Text);
ListBox4.Items.Add(Edit4.Text);
ListBox5.Items.Add(Edit5.Text);
ListBox6.Items.Add(Edit6.Text);
ListBox7.Items.Add(Edit7.Text);

Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
Edit6.Text:='';
Edit7.Text:='';
end
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
B:integer;
begin
A:=ListBox1.ItemIndex;
if A<0 then ShowMessage('Silinecek Kişiyi Seçiniz!')
else
begin
B:=Application.MessageBox('Seçilen Kişinin Kaydı Silinecektir!',
'DİKKAT',mb_YesNo+mb_IconQuestion);
if B=6 then
begin
ListBox1.Items.Delete(A);
ListBox2.Items.Delete(A);
ListBox3.Items.Delete(A);
ListBox4.Items.Delete(A);
ListBox5.Items.Delete(A);
ListBox6.Items.Delete(A);
ListBox7.Items.Delete(A);
end;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
A:=ListBox1.Items.IndexOf(Edit1.Text);
if A<0 then ShowMessage('Kayıt Bulunamadı')
else
begin
ListBox1.ItemIndex:=A;
ListBox2.ItemIndex:=A;
ListBox3.ItemIndex:=A;
ListBox4.ItemIndex:=A;
ListBox5.ItemIndex:=A;
ListBox6.ItemIndex:=A;
ListBox7.ItemIndex:=A;

ListBox1.TopIndex:=A;
ListBox2.TopIndex:=A;
ListBox3.TopIndex:=A;
ListBox4.TopIndex:=A;
ListBox5.TopIndex:=A;
ListBox6.TopIndex:=A;
ListBox7.TopIndex:=A;

Edit1.Text:=ListBox1.Items[A];
Edit2.Text:=ListBox2.Items[A];
Edit3.Text:=ListBox3.Items[A];
Edit4.Text:=ListBox4.Items[A];
Edit5.Text:=ListBox5.Items[A];
Edit6.Text:=ListBox6.Items[A];
Edit7.Text:=ListBox7.Items[A];
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
A:=ListBox1.ItemIndex;
if A<0 then ShowMessage('Değiştirilecek Kaydı Seçiniz!')
else
begin
ListBox1.Items[A]:=Edit1.Text;
ListBox2.Items[A]:=Edit2.Text;
ListBox3.Items[A]:=Edit3.Text;
ListBox4.Items[A]:=Edit4.Text;
ListBox5.Items[A]:=Edit5.Text;
ListBox6.Items[A]:=Edit6.Text;
ListBox7.Items[A]:=Edit7.Text;
end;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
A:=ListBox1.ItemIndex;
if A<0 then ShowMessage('Hangi Kaydın Önüne Ekleneceğini Seçiniz')
else
if Edit1.Text='' then ShowMessage('İsim Bilgileri Eksik')
else
begin
if (ListBox1.Items.IndexOf(Edit1.Text)>-1) and
(ListBox3.Items.IndexOf(Edit3.Text)>-1) then
ShowMessage('Aynı İsim ve Tel.sahip Kayıt Mevcuttur.')
else

begin
ListBox1.Items.Insert(A,Edit1.Text);
ListBox2.Items.Insert(A,Edit2.Text);
ListBox3.Items.Insert(A,Edit3.Text);
ListBox4.Items.Insert(A,Edit4.Text);
ListBox5.Items.Insert(A,Edit5.Text);
ListBox6.Items.Insert(A,Edit6.Text);
ListBox7.Items.Insert(A,Edit7.Text);
end;
end;
end;


procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
A:=Application.MessageBox('Dosyayı Kaydetmek İstermisiniz?',
'ÇIKIŞ',mb_YesNoCancel+mb_IconQuestion);
if A=6 then Button1.Click;{YES butonu tıklanısrsa A=6 olacaktır.}
if A=7 then Action:=caFree;{NO butonu tıklanısrsa A=7 olacaktır.}
if A=2 then Action:=caFree;{Cancel butonu tıklanısrsa A=2 olacaktır.}


end;
 
Sanıyorum sorunuzu yanlış forumda sormuşsunuz. Bunların VBA kodları olduğundan eminmisiniz.
 
Geri
Üst