
[HELP] Parseing in vb6
I am trying to learn how to parse information.
For my first time, I want a messagebox to be able to say
"Example of a simple HTML page"
(
http://help.nucleus.com/example_of_a_simple_html_page.htm)
So this is my code
Code:
Option Explicit
Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String
Dim lonStart As Long, lonEnd As Long
'1. Find start string.
lonStart = InStr(1, HTML, "<h1>", vbTextCompare)
If lonStart > 0 Then
'2. Move to end of start string.
lonStart = lonStart + Len("<h1>")
'3. Find end string.
lonEnd = InStr(lonStart, HTML, "</h1>", vbTextCompare)
If lonEnd > 0 Then
'4. Extract data between start and end strings.
GetBetween = Mid$(HTML, lonStart, lonEnd - lonStart)
'Done!
MsgBox GetBetween
End If
End If
End Function
Now how do I make it so that it know what site to go to and how do I also make it so that when I press "Command1" it will parse that information?
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
You will need to add an Inet Control to your form and make sure it's called 'Inet1'.
Code:
Option Explicit
private sub command1_click()
dim strhtml as string
strhtml = inet1.openurl("http://help.nucleus.com/example_of_a_simple_html_page.htm")
msgbox getbetween(1,strhtml,<h1>,</h1>)
end sub
Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String
Dim lonStart As Long, lonEnd As Long
'1. Find start string.
lonStart = InStr(1, data, startstring, comparemethod)
If lonStart > 0 Then
'2. Move to end of start string.
lonStart = lonStart + Len(startstring)
'3. Find end string.
lonEnd = InStr(lonStart, data, endstring, comparemethod)
If lonEnd > 0 Then
'4. Extract data between start and end strings.
GetBetween = Mid$(data, lonStart, lonEnd - lonStart)
End If
End If
End Function
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
Ok so now this is my whole code
Code:
Option Explicit
Private Sub command1_click()
Dim strhtml As String
strhtml = Inet1.OpenURL("http://help.nucleus.com/example_of_a_simple_html_page.htm")
msgbox getbetween(1,strhtml,<h1>,</h1>)
End Sub
Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String
Dim lonStart As Long, lonEnd As Long
'1. Find start string.
lonStart = InStr(1, HTML, "<h1>", vbTextCompare)
If lonStart > 0 Then
'2. Move to end of start string.
lonStart = lonStart + Len("<h1>")
'3. Find end string.
lonEnd = InStr(lonStart, HTML, "</h1>", vbTextCompare)
If lonEnd > 0 Then
'4. Extract data between start and end strings.
GetBetween = Mid$(HTML, lonStart, lonEnd - lonStart)
End If
End If
End Function
Syntax error on
Code:
Private Sub command1_click()
Dim strhtml As String
strhtml = Inet1.OpenURL("http://help.nucleus.com/example_of_a_simple_html_page.htm")
msgbox getbetween(1,strhtml,<h1>,</h1>)
End Sub
msgbox getbetween(1,strhtml,<h1>,</h1>) is red
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
umm, VB6 might need an equal sign (=) after msgbox? i forget....
Code:
msgbox = getbetween(1,strhtml,<h1>,</h1>)
try that.
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
Rawrrr
This is my whole code
Code:
Option Explicit
Private Sub command1_click()
Dim strhtml As String
strhtml = Inet1.OpenURL("http://help.nucleus.com/example_of_a_simple_html_page.htm")
msgbox = getbetween(1,strhtml,<h1>,</h1>)
End Sub
Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String
Dim lonStart As Long, lonEnd As Long
'1. Find start string.
lonStart = InStr(1, HTML, "<h1>", vbTextCompare)
If lonStart > 0 Then
'2. Move to end of start string.
lonStart = lonStart + Len("<h1>")
'3. Find end string.
lonEnd = InStr(lonStart, HTML, "</h1>", vbTextCompare)
If lonEnd > 0 Then
'4. Extract data between start and end strings.
GetBetween = Mid$(HTML, lonStart, lonEnd - lonStart)
End If
End If
End Function
Syntax error on
Code:
Private Sub command1_click()
Dim strhtml As String
strhtml = Inet1.OpenURL("http://help.nucleus.com/example_of_a_simple_html_page.htm")
msgbox = getbetween(1,strhtml,<h1>,</h1>)
End Sub
msgbox = getbetween(1,strhtml,<h1>,</h1>) is red
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
uhh whoops do this:
Code:
msgbox = getbetween(1,strhtml,"<h1>","</h1>")
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
lolwtf
"Compile Error:
Function call on left-hand side of assignment must return Variant or Object"
My whole code
Code:
Option Explicit
Private Sub command1_click()
Dim strhtml As String
strhtml = Inet1.OpenURL("http://help.nucleus.com/example_of_a_simple_html_page.htm")
MsgBox = GetBetween(1, strhtml, "<h1>", "</h1>")
End Sub
Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String
Dim lonStart As Long, lonEnd As Long
'1. Find start string.
lonStart = InStr(1, HTML, "<h1>", vbTextCompare)
If lonStart > 0 Then
'2. Move to end of start string.
lonStart = lonStart + Len("<h1>")
'3. Find end string.
lonEnd = InStr(lonStart, HTML, "</h1>", vbTextCompare)
If lonEnd > 0 Then
'4. Extract data between start and end strings.
GetBetween = Mid$(HTML, lonStart, lonEnd - lonStart)
End If
End If
End Function
Code:
Private Sub command1_click()
Dim strhtml As String
strhtml = Inet1.OpenURL("http://help.nucleus.com/example_of_a_simple_html_page.htm")
MsgBox = GetBetween(1, strhtml, "<h1>", "</h1>")
End Sub
Private Sub command1_click() is yellow
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
Remove the equal sign after the msgbox.... Dude you need to at least try instead of posting your errors and expecting others to fix them
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
Remove the equal sign after the msgbox.... Dude you need to at least try instead of posting your errors and expecting others to fix them
But I don't exactly know what the error means.. so I don't know what to fix =O
This is variable unidentified
Code:
[b]Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String[/b]
is highlighted =O
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
But I don't exactly know what the error means.. so I don't know what to fix =O
This is variable unidentified
Code:
[b]Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String[/b]
is highlighted =O
I can see the problem, i suggest you try looking for it.
I'll give you a hit, change one of your variable names to something the system doesn't already use.
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
So you're telling me that somewhere in
Code:
[b]Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String[/b]
is a variable that is not defined?
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
Then why is that code highlighted?
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
Then why is that code highlighted?
Because you are using a variable in that "GetBetween" function that isn't defined.....
You need to change one of the following variables:
Start
Data
StartString
EndString
to a variable you are using in your code, that you HAVEN'T declared....
If you can't work that out for yourself, i'm sorry but i'm not going to bother helping you...As i've already done 100% of what you were asking,..;
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
He pretty much just fixed the problem for you. Another thing, why are you using vb6? Its so old.
/facepalm
arg-highlightedPosts="Array"
args="" />

[HELP] Parseing in vb6
This is such A simple task.
Parsing one item from a site:
Code:
dim spSplit as string
spSplit = split(split(returnedData,"Tags Before")(Your delimeter example, 1"),"Tags After")(0)
Parsing more then one item:
Code:
dim sp() as string, i as long
sp() = split(returnedData,"Before Tags")
for i = 0 to ubound(sp())
sp(i) = split(sp(i),"After Tags")(0)
msgbox sp(i)
next i
Use:
Put it in your command button, make sure you name your objects.
Should work, I didn't open vb6 to test so...
arg-highlightedPosts="Array"
args="" />