Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » .NET Programming (VB 2010 or earlier) » ASP.NET » Searching A String, For A Match From Another...


Searching A String, For A Match From Another...Expand / Collapse
Author
Message
Posted 8/11/2009 7:46:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 8/25/2009 11:41:58 PM
Posts: 2, Visits: 6
So what I have is two strings.. Each string is a comma seperated value of two digit states. Like this

String 1:
"NV,CA,AZ"

String 2:
"ND,HI,CA"

What I need to do, is write some C# to check string 2, for a match in string 1. Meaning, If a state is listed in String 1, it should not appear in String 2. I have used "foreach" statements, but only for list boxes. I can seperate the strings, but am having an issue writing the code to compare the two. Here's what I got so far, it will check the first thing in each list, but will not go onto the second or third? How can I change the int inside String1[0] to +1 for every item in it's list?

Edit:
It would be awesome if the code could find the position of the match in the second string, and remove it. So if it finds CA from String1, in String2, it would remove it from String2.
1. string[] String1 = LabelAllStates.Text.Split(new char[] { ',' });
2. string[] String2 = LabelAllCountyStates.Text.Split(new char[] { ',' });
3.
4. foreach (String myCountyList in String1)
5. {
6. if (String1[0] == String2[0])
7. {
8. // Detected a match, therefore I fail validation
9. }
10. else
11. {
12. // No match found! Good job!
13. }
14. }


Best diet pills I Weight loss surgery
Post #28019
Posted 1/27/2010 8:52:29 AM


Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: 9/7/2010 12:29:54 PM
Posts: 633, Visits: 1,019
Check out regular expressions.



-Mobius
Post #28760
Posted 2/1/2010 6:31:12 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 6/8/2011 8:59:02 AM
Posts: 19, Visits: 20
Refer this link

http://www.vb6.us/tutorials/vb6-string-functions

http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingWithStringsP311232005021723AM/WorkingWithStringsP3.aspx

.NET Application Development | C# Development
Post #28802
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 2:59pm