|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|||
|
Quote:
This is a place for learning isn't it? How can you learn with out any visual code to view? Many Thanks, |
|
|||
|
As Nilpo is currently offline,
Do you know how the code can be adapted to search actual fields instead of the ":". At the moment the code searches the following string(s) in a multi line text field, and returns the data after the ":". Date: 12/12/06 Name: Bill Age: 19 Is there anyway the code can be adapted, to search the hole field, i.e. Date:, Name: Age:, with the ":" Reason why, as if the data in the text field contains a ":" the code screws up, and extracts the wrong data. This won't happen if the field name is included aswell i.e. Name: Many Thanks, Many Thanks, |
|
|||||||||||
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
vb Code:
__________________
Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! Last edited by Nilpo : February 8th, 2007 at 01:50 AM. |
|
|||
|
Thats the problem, i forgot to mention ealier that the textbox contains the following (including to new lines after "<Name> has sent the following information:"):
<Name> has sent the following information: Date: 12/12/06 Name: Bill Age: 19 Is there anyway the code can be adapted, to search the hole field, i.e. Date:, Name: Age:, with the ":" as if the data contains a ":" the program will get confused, and will therfore extract incorrect information. Many Thanks, much appreciated P.S Sorry to be a pain in the arse!!!! |
|
|||
|
Quote:
Code:
Dim sText As String Dim sDate As String Dim sName As String Dim sAge As String Dim arrText() As String Dim count As Integer sText = text1.text ' Get line count count = InStr(sText, vbNewLine) ' Size our dynamic array ReDim arrText(count) ' Split our text string into an array housing individual lines arrText = Split(sText, vbNewLine, -1, 1) ' Pull the last 3 strings from our array, ignoring any and all before it sDate = arrText(Ubound(arrText) - 3) sName = arrText(Ubound(arrText) - 2) sAge = arrText(Ubound(arrText) - 1) ' Parse each line for ": " followed by data entry and reassign to our variable sDate = Right(sDate, Len(sDate) - 4) sName = Right(sName, Len(sDate) - 4) sAge = Right(sAge, Len(sDate) - 3) |
|
|||
|
The code you post previously, doesn't search the textbox for the field names "Date:, Name:, & Age:" inorder to extract the data shown below.
Also if the contents of the textbox was to include an additional ":" say within the data, the program returns the wrong value. Is there anyway the code can be adapted, to search the hole field, i.e. Date:, Name: Age:, with the ":" as if the data contains an additional ":" within the data, the program STILL gets confused, and extracts incorrect information. CURRENT TEXTBOX CONTENTS: Date: 12/12/06 Name: Bill Age: 19 DATA EXTRACTED FROM TEXTBOX 12/12/06 Bill 19 Many Thanks, much appreciated! P.S Sorry to be a pain in the arse! :-) Last edited by Salchester : January 3rd, 2007 at 11:09 PM. |
|
|||
|
As email messages from Outlook Express, are going to be displayed one-by-one inside the textbox, the textbox will contain the same fields, but not necessarily the same data.
Can the code actually search the textbox for the below field names/strings and then extract the following data, as currently the fields are just trimmed out. Date: Name: Age: This is OK, only the textbox doesn't always contain the same information, for example the Name field may contain a long name and then a shorter name, leading to the program returning incorrect or partial data. Many Thanks, much appreciated!!! Last edited by Salchester : January 4th, 2007 at 11:21 AM. |
|
||||
|
Quote:
It will work. I've fully tested it here. |
|
|||
|
It doesn't work properly. If the textbox contains the following:
Bill has sent the following information: Date: 12/12/06 Name: Bill Age: 19 ..... the data extracted is as follows: : 12/12/06 : Bill Age: 19 instead of....... 12/12/06 Bill 19 and if the data is changed to the following: Peter Harper has sent the following information: Date: 12/12/2006 Name: Peter Harper Age: 19 ...... the data extracted is follows: : 12/12/2006 r Harper Age: 19 instead of........ 12/12/2006 Peter Harper 19 What needs to be changed to avoid this? Many Thanks, much appreciated! Last edited by Salchester : January 4th, 2007 at 12:48 PM. |
|
|||
|
Quote:
Many Thanks, much Appreciated! |
|
|||||
|
Sorry, there were typos in the last section.....try this:
vb Code:
Last edited by Nilpo : February 8th, 2007 at 01:51 AM. |
![]() |
| Viewing: Dev Hardware Forums > SOFTWARE > Programming > Parsing Strings |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|