-
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!
-
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
-
<?>
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
-
That won't work because the HTML is in a string! Saving the HTML to a file will slow down the program dramatically!
-
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.
-
<?>
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]
-
HeSaidJoe, also close the file.
-
<?>
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
-
Sorry, I din't see it because of the tabs. :rolleyes:
-
<?>
-
can any1 help me out! I need a better way!
-
<?>
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.
????