Click here to Skip to main content
15,883,894 members
Home / Discussions / C#
   

C#

 
Answer[Message Deleted] Pin
Matjaz-xyz18-Dec-08 3:32
Matjaz-xyz18-Dec-08 3:32 
GeneralRe: How come this If sentence doesnt work? Pin
Luc Pattyn18-Dec-08 3:41
sitebuilderLuc Pattyn18-Dec-08 3:41 
GeneralRe: How come this If sentence doesnt work? Pin
Matjaz-xyz18-Dec-08 3:44
Matjaz-xyz18-Dec-08 3:44 
GeneralRe: How come this If sentence doesnt work? Pin
Matjaz-xyz18-Dec-08 3:49
Matjaz-xyz18-Dec-08 3:49 
GeneralRe: How come this If sentence doesnt work? Pin
Dave Kreskowiak18-Dec-08 4:13
mveDave Kreskowiak18-Dec-08 4:13 
GeneralRe: How come this If sentence doesnt work? Pin
carbon_golem18-Dec-08 4:14
carbon_golem18-Dec-08 4:14 
AnswerRe: How come this If sentence doesnt work? Pin
carbon_golem18-Dec-08 4:23
carbon_golem18-Dec-08 4:23 
AnswerRe: How come this If sentence doesnt work? Pin
LongRange.Shooter18-Dec-08 7:40
LongRange.Shooter18-Dec-08 7:40 
Your problem displays the most common failure of beginning programmers -- mixing their 'AND' and their 'OR' logic.
You also need to think of how to address your other requirement that the text begin with 2,3,4, or 5.

A possible solution is first to write what you want out in text

if b starts with a valid number and textbox contains valid numbers then it's ok.
That leads to code such as this:


string b = "3.12321212";

List<char> validValues = new List<char> { '2', '3', '4', '5' };
List<string> validInput = new List<string> { "703", "733" };

textbox1.Text = "Not OK";

if ( validValues.Contains( b[0] ) && validInput.Contains( texbox.Text ) )
{
     textbox1.Text = "OK";
}


Another way you can also address this problem is with RegEx but I don't have the time to figure out the pattern.
AnswerRe: How come this If sentence doesnt work? Pin
Matjaz-xyz18-Dec-08 11:22
Matjaz-xyz18-Dec-08 11:22 
QuestionResX error after updating control Pin
liqnit18-Dec-08 3:16
liqnit18-Dec-08 3:16 
AnswerRe: ResX error after updating control Pin
Eddy Vluggen18-Dec-08 4:33
professionalEddy Vluggen18-Dec-08 4:33 
QuestionHow to get the final program? [modified] Pin
hanxing_c18-Dec-08 2:52
hanxing_c18-Dec-08 2:52 
AnswerRe: How to get the final program? Pin
hanxing_c18-Dec-08 2:57
hanxing_c18-Dec-08 2:57 
GeneralRe: How to get the final program? Pin
EliottA18-Dec-08 3:02
EliottA18-Dec-08 3:02 
AnswerRe: How to get the final program? Pin
Alan N18-Dec-08 3:04
Alan N18-Dec-08 3:04 
AnswerRe: How to get the final program? Pin
Simon P Stevens18-Dec-08 3:06
Simon P Stevens18-Dec-08 3:06 
AnswerRe: How to get the final program? Pin
Abhijit Jana18-Dec-08 3:10
professionalAbhijit Jana18-Dec-08 3:10 
AnswerRe: How to get the final program? Pin
benjymous18-Dec-08 3:10
benjymous18-Dec-08 3:10 
AnswerRe: How to get the final program? Pin
Tom Deketelaere18-Dec-08 3:11
professionalTom Deketelaere18-Dec-08 3:11 
AnswerRe: How to get the final program? Pin
Lev Danielyan18-Dec-08 3:11
Lev Danielyan18-Dec-08 3:11 
Answer[Message Deleted] Pin
hanxing_c18-Dec-08 3:16
hanxing_c18-Dec-08 3:16 
GeneralRe: How to get the final program? Pin
Dan Neely18-Dec-08 3:26
Dan Neely18-Dec-08 3:26 
GeneralRe: How to get the final program? Pin
Luc Pattyn18-Dec-08 3:44
sitebuilderLuc Pattyn18-Dec-08 3:44 
Questionadding stuff to labels from textboxes but creating new labels to populate as we go? Pin
Davey8518-Dec-08 0:54
Davey8518-Dec-08 0:54 
AnswerRe: adding stuff to labels from textboxes but creating new labels to populate as we go? Pin
Expert Coming18-Dec-08 0:59
Expert Coming18-Dec-08 0:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.