Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-02-2007, 11:21 AM   #1 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
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?
Salchester is offline   Reply With Quote
Old 01-02-2007, 06:23 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Well, let's look at the code. What do the second and third arguments to Mid$() do?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 01-03-2007, 03:30 AM   #3 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Quote:
Originally Posted by teknomage1 View Post
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?
Salchester is offline   Reply With Quote
Old 01-03-2007, 09:57 AM   #4 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
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
teknomage1 is offline   Reply With Quote
Old 01-03-2007, 12:09 PM   #5 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Quote:
Originally Posted by teknomage1 View Post
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?
Salchester is offline   Reply With Quote
Old 01-03-2007, 06:47 PM   #6 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
So what would happen if you changed those numbers to 2,6 ?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 01-03-2007, 09:38 PM   #7 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
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...
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-08-2007, 10:25 AM   #8 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
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?
Salchester is offline   Reply With Quote
Old 02-08-2007, 02:16 PM   #9 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
You've discussed this at following website as well (3 pages)
http://www.devhardware.com/forums/pr...gs-120294.html

Are you really learning?
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
qsort() fails on an array of char* strings fp_unit Standard C, C++ 1 01-28-2006 04:15 PM
Looping search strings. phill2000star PHP 4 07-18-2005 04:37 PM
New Tutorials: ASP Strings, and Visual Studio/VB.NET sde Code Newbie News 0 03-25-2004 06:37 PM
parsing [php] tags sde PHP 5 03-04-2003 12:59 PM


All times are GMT -8. The time now is 04:43 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting