check edit box value

This is a discussion on check edit box value within the Windows Programming forums, part of the Platform Specific Boards category; Hi I'm trying to verify if a edit box has been populated with data by the user. Here is some ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Location
    south africa
    Posts
    7

    check edit box value

    Hi

    I'm trying to verify if a edit box has been populated with data by the user. Here is some code:

    Code:
    void CFtpDlg::OnFtp() 
    {	
        if(m_sUser == " ")
        {
             AfxMessageBox("please enter user name");
             return;
        }
      
        //rest of code...
    }
    My problem is that no matter whether the box is empty or not, the message always gets displayed. Oh yeah and I do initialize m_sUser to " " before this function.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Well the answer depends on what data type m_sUser is.

    If it is a CString that is tied to an edit box (MFC Code), then you need to make sure and call UpdateData() so that m_sUser gets filled with what is in the edit box. Otherwise it will stay at its default value (" " in your case).

  3. #3
    Registered User
    Join Date
    Feb 2005
    Location
    south africa
    Posts
    7
    shot thanx!

    I've been messing around with UpdateDate() but I was passing it values (TRUE) & (FALSE). Needles to say it didn't work.

    Anyway thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. allegro issues
    By mramazing in forum C++ Programming
    Replies: 1
    Last Post: 01-07-2009, 11:56 PM
  2. edit box
    By beene in forum Windows Programming
    Replies: 3
    Last Post: 11-11-2006, 04:40 AM
  3. WS_HSCROLL in ES_READONLY edit box error
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 02-13-2006, 08:46 AM
  4. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 09:34 PM
  5. display a file in dropdown edit box
    By sunburnbyRA in forum Windows Programming
    Replies: 2
    Last Post: 03-10-2004, 01:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21