|
-
Nov 15th, 2000, 06:06 PM
#1
Thread Starter
Fanatic Member
Hey sup? I have a string with over 90 lines and I want to retrieve a whole line from this string! Can anyone help me do that? Don't forget, I have had a few codes before that work properly but if there's a line and then a double space and then there's another line, the code stops to work properly!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 16th, 2000, 07:04 AM
#2
Thread Starter
Fanatic Member
Clairifing things
Ok here's what my string looks like but it's a bit bigger!
Code:
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<IFRAME SRC="WHATEVER">
</BODY>
</HTML>
Lets say I want to retrieve the Line with the IFrame on it just by giving it the line number 8! So when I tell it to get line 8 I want it to get me the line with the <IFRAME SRC="WHATEVER"> ! Can anyone help me out! Thanx
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 16th, 2000, 07:13 AM
#3
_______
<?>
Code:
Private Sub Command1_Click()
Open "C:\my documents\try.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, mystring
i = i + 1
If i = 8 Then
MsgBox mystring
End If
Loop
Close #1
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 16th, 2000, 07:20 AM
#4
Thread Starter
Fanatic Member
That won't work because the HTML is in a string! Saving the HTML to a file will slow down the program dramatically!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 16th, 2000, 07:27 AM
#5
PowerPoster
VB Regular Expression
Actually you can use the VB Regular Expression to perform a very powerful sear in your plan text file. (Which I learn this from the Advisor.com) may be you can visit the web site or just download the VBScript.DLL from the microsoft web site.
I did create a sample program as the Advisor.com show, If you interest juz email me & I'll email it to you.
It really a create tools to manipulate a plan text file like HTML, XML, WML, ASP or any others.
-
Nov 16th, 2000, 07:38 AM
#6
_______
<?>
Code:
'here I put it in a string and split it and
'you always want 1 less than you want as arrays are
'zero based
Private Sub Command1_Click()
Open "C:\my documents\try.txt" For Input As #1
mystring = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
Dim myVar
myVar = Split(mystring, vbCrLf)
MsgBox myVar(7)
End Sub
You don't have to use the file like I did I just did it cause I was too lazy to create a string when I already had the content in a file.
[Edited by HeSaidJoe on 11-16-2000 at 08:14 AM]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 16th, 2000, 08:53 AM
#7
Fanatic Member
HeSaidJoe, also close the file.
-
Nov 16th, 2000, 08:56 AM
#8
_______
<?>
Code:
Say what?????
Private Sub Command1_Click()
Open "C:\my documents\try.txt" For Input As #1
mystring = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 16th, 2000, 08:58 AM
#9
Fanatic Member
Sorry, I din't see it because of the tabs.
-
Nov 16th, 2000, 09:05 AM
#10
_______
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 16th, 2000, 06:01 PM
#11
Thread Starter
Fanatic Member
can any1 help me out! I need a better way!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 16th, 2000, 06:43 PM
#12
_______
<?>
As I said in the edit, you don't need to import the file, I just used it cause I didn't have a string of html at hand.
The whole of my code was this.
Dim myVar
myVar = Split(mystring, vbCrLf)
As for better, what exactly do you want?
the code splits the string on vbCrlf and stores each
indivual line in an array from which you can pull any
line number you want. You only have to remember that the array is zero based so line 8 is line 7. And for that matter you can redim preserve myVar (1 to ubound(myVar)and then line 8 is line 8.
????
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|