0

I work in c# windows form vs 2015 selecting data from excel
problem i face it
supose i have in excel file
user id dateprint
1001 22/02/2017

if try add this user 1001 again with date 23/02/2017
it must give me message this user found before
but this is not happen and this is actually my problem
my code

bool c = QRC.UserExists(textBox1.Text);  

bool b = UserExistsToday();  

if (c == true)  

{  

if (b == true)  

{  

label8.Text = "User added today";  

}  

else  

{  

label8.Text = "User added before";  

}

Edited by Reverend Jim: Moved to programming forum

3
Contributors
2
Replies
11
Views
5 Months
Discussion Span
Last Post by Reverend Jim
0

While I wonder why the == true is there, in Visual Studio for over a decade I can break on the suspect line to examine the variables and see what's what. Try that.

0

I don't have a suggestion for a solution but I'd like to comment on the code. I've taken the above code and rewritten it as

if (QRC.UserExists(textBox1.Text))  
{  
    if (UserExistsToday())  
    {  
        label8.Text = "User added today";  
    }  
    else  
    {  
        label8.Text = "User added before";  
    }

without getting into a discussion as to the preference for same-line or separate-line brace brackets, can you see how removing some white space and the unnecessary b and c variables (which are not named to be descriptive), the code is now much easier to read?

Edited by Reverend Jim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.