Results 1 to 7 of 7

Thread: How to only allow integers on a TEdit

  1. #1
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default How to only allow integers on a TEdit

    How would i only allow integers to be typed into the TEdit and then have them used say for an inventory number.

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    StrToIntDef(TEditBox.Text, DefaultValueIfUserEntersCrap);
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    How would that go in and where for Tedit

    Simba Code:
    Edit3 := TEdit.Create(FrmDesign);
      Edit3.Parent := FrmDesign;
      Edit3.Top := 350;
      Edit3.Left := 75;
      Edit3.Width := 100;
      Edit3.Height := 27;

    all i want this to do isbe able to change a global variable known as

    InvNumber: Integer;

  4. #4
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    ill assume you learnt this from tutorial and you have this procedure

    Simba Code:
    Procedure ButtonClick(Sender: TObject);
    Begin
      frmDesign.ModalResult:= mrOk;
      InvNumber:=StrToInt(Edit3.text);//you need to convert the value entered from a string
    End;

    that should work
    Last edited by Mark; 01-15-2012 at 04:48 PM.

  5. #5
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  6. #6
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by Mark View Post
    ill assume you learnt this from tutorial and you have this procedure

    Simba Code:
    Procedure ButtonClick(Sender: TObject);
    Begin
      frmDesign.ModalResult:= mrOk;
      InvNumber:=StrToInt(Edit3.text);//you need to convert the value entered from a string
    End;

    that should work
    can you explain how that works? if a user enters 981c for his bank pin what does it do? ignore the c?

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  7. #7
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    would cause an error
    BankPin Invalid Int value "981c"

    you could make a check for this.
    But really tho your not going to enter a letter to a number only field like bank pin without you noticing.
    Previously Known or not Known as CRU1Z1N.
    If you want to succeed you should strike out on new paths, rather than travel the worn paths of accepted success.(John D. Rockefeller)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •