|
 |
|
 |
01-02-2007, 11:21 AM
|
#1 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
Parsing Strings
I currently have some text in a multiline textbox, how can the the following code be adapted to parse characters 3 to 8 on line 1 of the textbox. Then characters 2 to 6 on line to of the text box, and store both extracted strings in two separate variables.
The following code extracts from line 1 then store the extracted string inside sMidText
Code:
Dim sText As String
Dim sMidText As String
sText = text1.text
sMidText = Mid$(sText, 3, 8)
Debug.Print sMidText
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
01-02-2007, 06:23 PM
|
#2 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
|
Well, let's look at the code. What do the second and third arguments to Mid$() do?
__________________
Stop intellectual property from infringing on me
|
|
|
01-03-2007, 03:30 AM
|
#3 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
Quote:
Originally Posted by teknomage1
Well, let's look at the code. What do the second and third arguments to Mid$() do?
|
Sorry, do you mean the argument shown below in bold?
Code:
Dim sText As String
Dim sMidText As String
sText = text1.text
sMidText = Mid$(sText, 3, 8)
Debug.Print sMidText
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
01-03-2007, 09:57 AM
|
#4 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
|
Yep, those arguments. What is the function of each one?
Extrapolating, what would the consequences of changing them to different numbers be?
__________________
Stop intellectual property from infringing on me
|
|
|
01-03-2007, 12:09 PM
|
#5 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
Quote:
Originally Posted by teknomage1
Yep, those arguments. What is the function of each one?
Extrapolating, what would the consequences of changing them to different numbers be?
|
The arguments basic tell VB what characters to extract.
Extract characters 3 to 8 within a string.
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
01-03-2007, 06:47 PM
|
#6 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
|
So what would happen if you changed those numbers to 2,6 ?
__________________
Stop intellectual property from infringing on me
|
|
|
01-03-2007, 09:38 PM
|
#7 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
|
His problem is not extracting things with the use of the Mid$() function, it is locating the second line and extracting the next seequence from that...
If he was smart, he'd cyckle through the text looking for '\n' and when one is reached, call Mid$() with the matching substring to be extracted depending on what line number is reached..
Now he just have to figure out the function to call which will do just that...
I know in C I probably would have used strchr() in a combination with strtok(), but since I always thought VB would introduce bad coding practice, I know Jack sh** about VB, so for now this is the only advice I can give...
|
|
|
02-08-2007, 10:25 AM
|
#8 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
Yes, but wouldn't that extract all information on that line, rather than just a few characters?
Many Thanks, much appreciated!!!
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 04:43 AM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|