if statements
-
I am trying to right an if statement for a project that pulls data from a table. like for instancte I have int Mem = 0; if (Mem ==1)//for true { lbMember.text = applicant.getfname() +" "+ applicant.getlname(); lbAdd.Text = address.getAddress(); } else lbMember.text = "not selected"; } when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in. Thanks in advance
-
I am trying to right an if statement for a project that pulls data from a table. like for instancte I have int Mem = 0; if (Mem ==1)//for true { lbMember.text = applicant.getfname() +" "+ applicant.getlname(); lbAdd.Text = address.getAddress(); } else lbMember.text = "not selected"; } when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in. Thanks in advance
Please rephrase as I can't understand what it is you want. I would be glad to help, otherwise.
TWatson47 wrote:
when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
-
Please rephrase as I can't understand what it is you want. I would be glad to help, otherwise.
TWatson47 wrote:
when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
when I set the values to 0 or 1, it is like I am forcing the statement to be true or false. Like if there is no joint member, I would like it to be false and use the else statement. If there is a joint member I would like it to be true and use the if statement. How should write the code to allow the selection to come from when they input the criteria. Thanks so much for your help and speedy response
-
when I set the values to 0 or 1, it is like I am forcing the statement to be true or false. Like if there is no joint member, I would like it to be false and use the else statement. If there is a joint member I would like it to be true and use the if statement. How should write the code to allow the selection to come from when they input the criteria. Thanks so much for your help and speedy response
I still have no idea what you are asking.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
-
I am trying to right an if statement for a project that pulls data from a table. like for instancte I have int Mem = 0; if (Mem ==1)//for true { lbMember.text = applicant.getfname() +" "+ applicant.getlname(); lbAdd.Text = address.getAddress(); } else lbMember.text = "not selected"; } when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in. Thanks in advance
TWatson47 wrote:
int Mem = 0; if (Mem ==1)//for true
Not trying to second guess your logic, but why wouldn't you want to use a
bool
type variable to do this?bool mem = false;
// Some code that modifies the state of "mem"
if (mem) {
lbMember.text = applicant.getfname() +" "+ applicant.getlname();
lbAdd.Text = address.getAddress();
} else {
// mem == false
lbMember.text = "not selected";
}Why co-opt an
int
? That's a retro, "C"-type thing to do... Just wondering. Sean -
I am trying to right an if statement for a project that pulls data from a table. like for instancte I have int Mem = 0; if (Mem ==1)//for true { lbMember.text = applicant.getfname() +" "+ applicant.getlname(); lbAdd.Text = address.getAddress(); } else lbMember.text = "not selected"; } when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in. Thanks in advance
Are you saying you want to base your if/else on user input? If so you can add a radio button with yes and no and do something like this
if (rbMember.SelectedItem.Text == Yes) { // blah blah } else { // blah blah }
-
I still have no idea what you are asking.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
ok, I will try to explain a little better. I have created some forms that say for instance a new member comes into a bank and want a loan. When the Agent puts there info into a build it is then saved to a server(database). The Idea is to have there info pull up with the selected loan form that they are wanting. Say for instance a auto loan. I have been able to pull the form with there info on it fine. However, I wanted to add some logic in place that looks to see if there is a joint member. If there is then hit all the tables requesting the joint information and load to the form. My problem is that when I set the variable, say for instance Jmem = 0, even if there is a joint member it comes up as false, and gives the else statement. My question is what do I need to add to the previous if statement that will except the joint member as true. The same if for beneficiary also. I hope this helps in understanding Thanks
-
ok, I will try to explain a little better. I have created some forms that say for instance a new member comes into a bank and want a loan. When the Agent puts there info into a build it is then saved to a server(database). The Idea is to have there info pull up with the selected loan form that they are wanting. Say for instance a auto loan. I have been able to pull the form with there info on it fine. However, I wanted to add some logic in place that looks to see if there is a joint member. If there is then hit all the tables requesting the joint information and load to the form. My problem is that when I set the variable, say for instance Jmem = 0, even if there is a joint member it comes up as false, and gives the else statement. My question is what do I need to add to the previous if statement that will except the joint member as true. The same if for beneficiary also. I hope this helps in understanding Thanks
If that is the case consider using booleans. Also from what I can gather it entirely possible that your value is not being set correctly if the if statement is not evaluating. Try setting a break on the if and checking the value of the variables. There are a lot of particular scenarios that can be causing your problem but the code
int mem = 0;
..some code that may reset me
if(mem == 1){
...
}
else{
...
}is valid.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
-
TWatson47 wrote:
int Mem = 0; if (Mem ==1)//for true
Not trying to second guess your logic, but why wouldn't you want to use a
bool
type variable to do this?bool mem = false;
// Some code that modifies the state of "mem"
if (mem) {
lbMember.text = applicant.getfname() +" "+ applicant.getlname();
lbAdd.Text = address.getAddress();
} else {
// mem == false
lbMember.text = "not selected";
}Why co-opt an
int
? That's a retro, "C"-type thing to do... Just wondering. SeanI am new to C# I use to write in C++. Your idea looked good, however, I am still having the same problem. I am still get a false reaction even though it is true. I am getting a read out of "not selected" when it should be the members info. Any suggestions, it looked like you where on the right path. Thanks for the help
-
If that is the case consider using booleans. Also from what I can gather it entirely possible that your value is not being set correctly if the if statement is not evaluating. Try setting a break on the if and checking the value of the variables. There are a lot of particular scenarios that can be causing your problem but the code
int mem = 0;
..some code that may reset me
if(mem == 1){
...
}
else{
...
}is valid.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
-
I am trying to right an if statement for a project that pulls data from a table. like for instancte I have int Mem = 0; if (Mem ==1)//for true { lbMember.text = applicant.getfname() +" "+ applicant.getlname(); lbAdd.Text = address.getAddress(); } else lbMember.text = "not selected"; } when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in. Thanks in advance
TWatson47 wrote:
how do I get it to make the selection of choice from where the data is put in.
I'm not sure what you mean ? If you mean the UI provides the case, use a checkbox.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
I am trying to right an if statement for a project that pulls data from a table. like for instancte I have int Mem = 0; if (Mem ==1)//for true { lbMember.text = applicant.getfname() +" "+ applicant.getlname(); lbAdd.Text = address.getAddress(); } else lbMember.text = "not selected"; } when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in. Thanks in advance
The code that you are showing is perfectly valid, and will never have the problems that you are talking about. Therefore: :: Your code is different in some way from the code that you have shown. :: Either the variable doesn't contain what you think it does, or you are doing the comparison wrong.
--- b { font-weight: normal; }
-
Thanks for you help. That is excactly how I had it coded, I just wasn't sure why I was having the problems. I even tried using bool mem = false; if(mem) {... } else {... } and it did the same thing.
Is your project building? If you have an incorrect version the debugger will still step but perform strange actions. Very confusing but it happens.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
-
I am trying to right an if statement for a project that pulls data from a table. like for instancte I have int Mem = 0; if (Mem ==1)//for true { lbMember.text = applicant.getfname() +" "+ applicant.getlname(); lbAdd.Text = address.getAddress(); } else lbMember.text = "not selected"; } when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in. Thanks in advance
-
Your question interests me. What value are you storing in the database to indicate it is a joint or individual loan?
okay what it sounds like is that you are trying to get data from a database and use that value to do a specific action you obviosly need someway of obtaining that data from the database i don't know how you have this information stored but if its in some sort of class then you would do something like
if(Loan.JointAccount == "MyWife") { do logic here } else { do non joint logic here }
-
I am trying to right an if statement for a project that pulls data from a table. like for instancte I have int Mem = 0; if (Mem ==1)//for true { lbMember.text = applicant.getfname() +" "+ applicant.getlname(); lbAdd.Text = address.getAddress(); } else lbMember.text = "not selected"; } when I use int Mem = 0; I will get the else statement when I use int Mem = 1; then I get the if selection how do I get it to make the selection of choice from where the data is put in. Thanks in advance
Hi, i think i got ur question. wat about adding a checkbox to your form. when it is selected you can set the value to true and take steps accordingly. and if its not selected ie. false and you can perform the steps for false value. hope this works. Nitin...