Hello everyone,
First off, I would like to thank all of you for your contributions to this site. Searching thru the posts here has saved my sanity on multiple occasions.
I am just getting started in VB.NET and I am using Visual Studio 2008. What I am trying to do is open an Access Database and go to a specific table. In that table, I go to a specific row and search for the word "NAME:". Everything I posted above I can get to work. Here's where I am having issues. The records I am trying to parse out of the database are, of course, names. The problem is, this is what the database looks like:
NAME:SMITH JOHN A DOB:01-01-1980 PRN:32275664892009 ADD:123 ANYWHERE ST
What I am trying to do is parse out the last name, first name, middle initial, date of birth (DOB), property resource number (PRN) and the address (ADD). I can get this do happen but I am doing it by finding the word NAME: and taking everything after the : and then looking for the first space. After I find the first space, I grab the next character and look for the next space and so on. This works fairly well until I get something like this:
NAME:LA LOW JENNIFER P
What happens then is I am getting LA for the last name, LOW for the first name, and JENNIFER for the middle...
Also...
Sometimes (remember this is an old database that I am trying to pull the data out of), sometimes it has something like this:
NAME:SMITH JOHN A DOB:01-01-1980 PRN:1234567890 OR SMITH JANE A DOB:04-05-1980 PRN:0987654321
I search for the word "OR" (which is also sometimes "AND" - it's hit and miss, so I need to figure out how to search for "OR" or "AND") and if there are two people registered to the property, all is good. If not, the program goes to th next line until it finds the word "OR" and grabs that info, so it is giving me the second person who owns the land but from a different land parcel. So I need to make it stop searching for "OR" (or "AND") within the same line of data.
Ok - after I confused you all now (and myself), here's what I have for code so far...
*******************************************************
strNAME1 = (ds.Tables("Property").Rows(inc).Item(0).ToString)
intFindNAME = Microsoft.VisualBasic.InStr(strRO1, "NAME:")
If intFindNAME <> 0 Then
intFindLast1 = Microsoft.VisualBasic.InStr(intFindNAME, strNAME1, " ")
If intFindLast1 <> 0 Then
strLastName1 = Microsoft.VisualBasic.Mid(strNAME1, intFindNAME + 4, intFindLast1 - (intFindNAME + 5))
intFindFirst1 = Microsoft.VisualBasic.InStr(intFindLast1 + 1, strRO1, " ")
If intFindFirst1 <> 0 Then
strFirstName1 = Microsoft.VisualBasic.Mid(strNAME1, intFindLast1 + 1, intFindFirst1 - intFindLast1)
intFindMid1 = Microsoft.VisualBasic.InStr(intFindFirst1 + 1, strNAME1, " ")
If intFindMid1 <> 0 Then
strMiddleInitial1 = Microsoft.VisualBasic.Mid(strNAME1, intFindFirst1 + 1, intFindMid1 - intFindFirst1)
intFindDOB1 = Microsoft.VisualBasic.InStr(intFindMid1 + 1, strNAME1, " ")
If intFindDOB1 <> 0 Then
strDOB1 = Microsoft.VisualBasic.Mid(strNAME1, intFindMid1 + 1, intFindDOB1 - intFindMid1)
strDOB1 = Microsoft.VisualBasic.Left(strDOB1, +14)
strDOB1 = Microsoft.VisualBasic.Right(strDOB1, +10)
********************************************************
That's just to find the last name, first name, and DOB of the first person. I am sure I am not going about the best way to parse out this info. Could someone give me some pointers as to how to do this better and how to solve some of the issues I mentioned above? I am a complete newbie to VB.NET so any help is appreciated.
Thank you to everyone for reading this and for your time.
Pellet
First off, I would like to thank all of you for your contributions to this site. Searching thru the posts here has saved my sanity on multiple occasions.
I am just getting started in VB.NET and I am using Visual Studio 2008. What I am trying to do is open an Access Database and go to a specific table. In that table, I go to a specific row and search for the word "NAME:". Everything I posted above I can get to work. Here's where I am having issues. The records I am trying to parse out of the database are, of course, names. The problem is, this is what the database looks like:
NAME:SMITH JOHN A DOB:01-01-1980 PRN:32275664892009 ADD:123 ANYWHERE ST
What I am trying to do is parse out the last name, first name, middle initial, date of birth (DOB), property resource number (PRN) and the address (ADD). I can get this do happen but I am doing it by finding the word NAME: and taking everything after the : and then looking for the first space. After I find the first space, I grab the next character and look for the next space and so on. This works fairly well until I get something like this:
NAME:LA LOW JENNIFER P
What happens then is I am getting LA for the last name, LOW for the first name, and JENNIFER for the middle...
Also...
Sometimes (remember this is an old database that I am trying to pull the data out of), sometimes it has something like this:
NAME:SMITH JOHN A DOB:01-01-1980 PRN:1234567890 OR SMITH JANE A DOB:04-05-1980 PRN:0987654321
I search for the word "OR" (which is also sometimes "AND" - it's hit and miss, so I need to figure out how to search for "OR" or "AND") and if there are two people registered to the property, all is good. If not, the program goes to th next line until it finds the word "OR" and grabs that info, so it is giving me the second person who owns the land but from a different land parcel. So I need to make it stop searching for "OR" (or "AND") within the same line of data.
Ok - after I confused you all now (and myself), here's what I have for code so far...
*******************************************************
strNAME1 = (ds.Tables("Property").Rows(inc).Item(0).ToString)
intFindNAME = Microsoft.VisualBasic.InStr(strRO1, "NAME:")
If intFindNAME <> 0 Then
intFindLast1 = Microsoft.VisualBasic.InStr(intFindNAME, strNAME1, " ")
If intFindLast1 <> 0 Then
strLastName1 = Microsoft.VisualBasic.Mid(strNAME1, intFindNAME + 4, intFindLast1 - (intFindNAME + 5))
intFindFirst1 = Microsoft.VisualBasic.InStr(intFindLast1 + 1, strRO1, " ")
If intFindFirst1 <> 0 Then
strFirstName1 = Microsoft.VisualBasic.Mid(strNAME1, intFindLast1 + 1, intFindFirst1 - intFindLast1)
intFindMid1 = Microsoft.VisualBasic.InStr(intFindFirst1 + 1, strNAME1, " ")
If intFindMid1 <> 0 Then
strMiddleInitial1 = Microsoft.VisualBasic.Mid(strNAME1, intFindFirst1 + 1, intFindMid1 - intFindFirst1)
intFindDOB1 = Microsoft.VisualBasic.InStr(intFindMid1 + 1, strNAME1, " ")
If intFindDOB1 <> 0 Then
strDOB1 = Microsoft.VisualBasic.Mid(strNAME1, intFindMid1 + 1, intFindDOB1 - intFindMid1)
strDOB1 = Microsoft.VisualBasic.Left(strDOB1, +14)
strDOB1 = Microsoft.VisualBasic.Right(strDOB1, +10)
********************************************************
That's just to find the last name, first name, and DOB of the first person. I am sure I am not going about the best way to parse out this info. Could someone give me some pointers as to how to do this better and how to solve some of the issues I mentioned above? I am a complete newbie to VB.NET so any help is appreciated.
Thank you to everyone for reading this and for your time.
Pellet