Thread: Editbox help

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    4

    Editbox help

    Hi, im new to the fun world of C++, learning it gradually as i go...

    i have figured how to use the data the user enters in to an editbox like so

    Code:
    if(CheckBox21->Checked)
    {
    wac<<"if never() then"<<endl;
    wac<<"breathtime ="<<Edit3->Text.c_str()<<endl;
    wac<<"endif"<<endl;
    wac<<endl;
    }
    but what i would like to do, is divide the users input by half.

    so if they enter 20, it will create

    if never() then
    breathtime = 10
    endif

    in the wac file.

    any help with this would be appreciated

    Edit:

    ive added this to the "on key press" of the editbox

    Code:
    void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key)
    {
    if ((Key < 48 || Key > 57) && Key != 8) Key = 0;
    }
    so now only numerical datacan be entered.... just leaves the division
    Last edited by brad.g; 01-10-2006 at 02:21 PM.

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    Code:
    #include<cstdlib>
    
    //Convert from CString to int, then divide by 2
    wac<<"breathtime ="<< atoi(Edit3->Text.c_str()) / 2 <<endl;
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Jan 2006
    Posts
    4
    Thanks alot for your help . il read through the FAQ's before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 08-25-2005, 03:09 PM
  2. Create two buttons that interact with an editbox
    By Arkanos in forum Windows Programming
    Replies: 8
    Last Post: 07-13-2005, 12:56 AM
  3. Create two buttons that interact with an editbox
    By Arkanos in forum C++ Programming
    Replies: 4
    Last Post: 07-11-2005, 01:17 AM
  4. editbox problem
    By tyouk in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2004, 09:14 PM
  5. Editbox problems
    By Devil Panther in forum Windows Programming
    Replies: 9
    Last Post: 07-27-2003, 04:12 PM