PDA

Tam Sürümünü Görmek İçin : Bir türlü halledemedim


KAFAYI-7M
22/06/2003, 15:13
Delphi 7 ile bi program yazıyorum... Herşey tamam ama tek bişi var...
Onu birtürlü halledemiyorum...
Edit kutusuna boşluk yazınca ListBox'a kaydedio...
Ben bütün yolları denedim ama başaramadım...
Yardımcı olabilir misiniz?


unit Uinlerim1;

interface

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

type
TForm1 = class(TForm)
UinekleBox: TGroupBox;
UinekleEdit: TEdit;
EkleButton: TButton;
UinlerimBox: TGroupBox;
ListBox1: TListBox;
SilButton: TButton;
AnaMenu: TMainMenu;
K7Menu: TMenuItem;
Label1: TLabel;
Label2: TLabel;
KapatMenu: TMenuItem;
procedure EkleButtonClick(Sender: TObject);
procedure SilButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure KapatMenuClick(Sender: TObject);
procedure K7MenuClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses Uinlerim2;

{$R *.dfm}

procedure TForm1.EkleButtonClick(Sender: TObject);
Var
p:Integer;
begin
p:=Pos(' ', UinekleEdit.Text);
If p=0 Then
If ListBox1.Items.IndexOf(UinekleEdit.Text)>-1 Then
ShowMessage(UinekleEdit.Text+' nolu uin zaten listede mevcut!')
Else
ListBox1.Items.Add(UinekleEdit.Text);
end;

procedure TForm1.SilButtonClick(Sender: TObject);
Var Secili:Integer;
begin
Secili:=ListBox1.ItemIndex;
If Secili<0 Then
ShowMessage('Silinecek olan uini seçmedin')
Else
Begin
ListBox1.Items.Delete(ListBox1.ItemIndex);
End;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
c:Word;
begin
c:=Application.MessageBox('Değişiklikleri kaydetmek istiyor musunuz?','Uinlerim - Çıkış', MB_YESNOCANCEL + MB_ICONQUESTION);
case c of
IDYES : ListBox1.Items.SaveToFile('uinlerim.dat');
IDCANCEL : Action:=caNone;
End;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
If FileExists('uinlerim.dat') then
Begin
ListBox1.Items.LoadFromFile('uinlerim.dat');
End;
Label2.Caption:=IntToStr(ListBox1.Items.Count);
end;

procedure TForm1.KapatMenuClick(Sender: TObject);
begin
Close;
end;

procedure TForm1.K7MenuClick(Sender: TObject);
begin
Form2.Visible:=True;
end;

end.


Veya çözüm olarak düşündüğüm: kullanıcının edit kutusuna sadece rakam girmesini (listbox'a ekleyen buton denetleyecek şekilde) veya direk olarak harflere bastığında kutuya yazmayacak şekilde nasıl yapabilirim?


farukcalikusu
29/06/2003, 16:26
Kullanıcının edit kutusuna sadece rakam girmesini istiyorsan
try except var onu bir dene;

---
procedure TForm1.Button1Click(Sender: TObject);
begin
try
StrToInt(Edit1.Text);
ShowMessage('rakam girdiniz.');
except
ShowMessage('Lütfen sadece rakam giriniz.');
exit;
end;

end;
---

yanlız proje dizaydayken denediğinde hata verecektir. projeyi exe den çalıştırırsan sorun olmayacaktır.

KAFAYI-7M
29/06/2003, 22:20
Neyse dostum çoktan hallettim...
İsteyen varsa kodunu verebilirim... Saolasın...