Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how can I warn to make a choice for numeric edit box?

how can I warn to make a choice for numeric edit box?

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Emre Zorlu
    wrote on last edited by
    #1

    When I add information to access table ,I use this code ! set.m_access_attribute = GetDlgItemInt (IDC_EDIT1); How can I warn to fill edit box if it is forgotten:confused: ? emroz

    T 1 Reply Last reply
    0
    • E Emre Zorlu

      When I add information to access table ,I use this code ! set.m_access_attribute = GetDlgItemInt (IDC_EDIT1); How can I warn to fill edit box if it is forgotten:confused: ? emroz

      T Offline
      T Offline
      Toni78
      wrote on last edited by
      #2

      GetDlgItemInt has two more parameters. The actual syntax is: UINT GetDlgItemInt( int nID, BOOL* lpTrans = NULL, BOOL bSigned = TRUE ) const; If the edit box doesn't contain a valid numeric value then pTrans would become 0.

      BOOL pTrans;
      int iValue = GetDlgItemInt( IDC_EDIT1, &pTrans );
      if( pTrans == 0 )
      AfxMessageBox( "Please enter a numerical value!");
      else
      set.m_access_attribute = iValue;

      I haven't tried to compile the code so it might contain errors. Another way is to force the edit box accept only integers and that can be done in the resource editor. Right-click on the edit box, select properties, and then in the styles tab select Number. // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups