|
-
Apr 22nd, 2007, 02:58 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Between
Hi, is there a way to show the text that is between something?
like this.
if i have this code
Image Code:
<input class="text" onClick='highlight(this);' value="[url=http://www.imgupp.com/uploads/pubtrick694407.jpg]  [/url]"
and i would like to show the text that are between [url and jpg] means http://www.imgupp.com/uploads/pubtrick694407
is there a way to do this?
tanks
-
Apr 22nd, 2007, 03:27 PM
#2
Hyperactive Member
Re: Between
You can use IndexOf to find url= and .jpg then substring
Code:
'find url= and add 4 because we want the string after it
Dim start As Integer = yourstring.IndexOf("url=") + 4
'find .jpg
Dim finish As Integer = yourstring.IndexOf(".jpg")
'show the string between the index's found
MessageBox.Show(yourstring.Substring(start, finish - start))
-
Apr 22nd, 2007, 03:35 PM
#3
Thread Starter
Frenzied Member
Re: Between
when u say yourstring u mean the .jpg ... ?
Last edited by met0555; Apr 22nd, 2007 at 04:04 PM.
-
Apr 23rd, 2007, 12:05 AM
#4
Re: Between
He means the string that you want to get the substring of. "yourstring" means the string that you're using, i.e. your string.
-
Apr 23rd, 2007, 02:54 AM
#5
Thread Starter
Frenzied Member
Re: Between
Well, i've tried it as i understand it . And i've got this error
Code:
Length cannot be less than zero.
Parameter name: length
vb Code:
Dim mystring As String
mystring = "mystring"
'find url= and add 4 because we want the string after it
Dim start As Integer = mystring.IndexOf("url=") + 4
'find .jpg
Dim finish As Integer = mystring.IndexOf(".jpg")
'show the string between the index's found
MessageBox.Show(mystring.Substring(start, finish - start))
Last edited by met0555; Apr 23rd, 2007 at 02:57 AM.
-
Apr 23rd, 2007, 03:53 AM
#6
Re: Between
Do you know what argument of what method that error message is talking about? What line did it occur on? What method on that line has an parameter named "length"? What is the value of that parameter when you call the method? How is that value calculated?
-
Apr 23rd, 2007, 03:57 AM
#7
Thread Starter
Frenzied Member
Re: Between
i know it's talking about
vb Code:
MessageBox.Show(mystring.Substring(start, finish - start))
-
Apr 23rd, 2007, 04:10 AM
#8
Re: Between
So what about my other questions? This is how you solve problems. There isn't much code on that line so it shouldn't be too hard to work out which is the "length" parameter. Once you know that then you can check it's value. The error message says that it's less than zero and it's not allowed to be. How was it calculated? How did it get to be less than zero? Is it a data error or a logic error?
-
Apr 23rd, 2007, 04:54 AM
#9
Thread Starter
Frenzied Member
Re: Between
ok, i get what it was wrong, now my problem is i'm trying to select a text from an .html ("C:\tempsysfile.html") file, how do i do that?
-
Apr 23rd, 2007, 07:39 PM
#10
Re: [RESOLVED] Between
HTML files are just plain text. You read them the same way(s) as any other text file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|