 |

03-26-2011, 07:54 PM
|
|
Active Member
|
|
Join Date: May 2006
Posts: 122
|
|
[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..._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?
|

03-26-2011, 11:30 PM
|
 |
Creator of EliteSwitch
|
|
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
|
|
Re: [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
|

03-27-2011, 06:44 AM
|
|
Active Member
|
|
Join Date: May 2006
Posts: 122
|
|
Re: [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
Last edited by dgameman1 : 03-27-2011 at 06:47 AM.
|

03-27-2011, 10:58 AM
|
 |
Creator of EliteSwitch
|
|
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
|
|
Re: [HELP] Parseing in vb6
umm, VB6 might need an equal sign (=) after msgbox? i forget....
Code:
msgbox = getbetween(1,strhtml,<h1>,</h1>)
try that.
|

03-27-2011, 08:10 PM
|
|
Active Member
|
|
Join Date: May 2006
Posts: 122
|
|
Re: [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
|

03-27-2011, 09:04 PM
|
 |
Creator of EliteSwitch
|
|
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
|
|
Re: [HELP] Parseing in vb6
uhh whoops do this:
Code:
msgbox = getbetween(1,strhtml,"<h1>","</h1>")
Last edited by Covey : 03-27-2011 at 09:07 PM.
|

03-27-2011, 09:22 PM
|
|
Active Member
|
|
Join Date: May 2006
Posts: 122
|
|
Re: [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
Last edited by dgameman1 : 03-27-2011 at 09:22 PM.
|

03-28-2011, 02:23 AM
|
 |
Creator of EliteSwitch
|
|
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
|
|
Re: [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
|

03-28-2011, 02:28 AM
|
|
Active Member
|
|
Join Date: May 2006
Posts: 122
|
|
Re: [HELP] Parseing in vb6
Quote:
Originally Posted by Covey
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:
Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String
is highlighted =O
|

03-28-2011, 12:02 PM
|
 |
Creator of EliteSwitch
|
|
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
|
|
Re: [HELP] Parseing in vb6
Quote:
Originally Posted by dgameman1
But I don't exactly know what the error means.. so I don't know what to fix =O
This is variable unidentified
Code:
Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String
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.
|

03-29-2011, 12:06 AM
|
|
Active Member
|
|
Join Date: May 2006
Posts: 122
|
|
Re: [HELP] Parseing in vb6
So you're telling me that somewhere in
Code:
Private Function GetBetween(ByVal Start As Long, Data As String, _
StartString As String, EndString As String, _
Optional ByVal CompareMethod As VbCompareMethod = vbBinaryCompare) As String
is a variable that is not defined?
|

03-29-2011, 02:13 AM
|
 |
Creator of EliteSwitch
|
|
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
|
|
Re: [HELP] Parseing in vb6
Incorrect
|

03-29-2011, 02:45 AM
|
|
Active Member
|
|
Join Date: May 2006
Posts: 122
|
|
Re: [HELP] Parseing in vb6
Then why is that code highlighted?
|

03-29-2011, 10:31 AM
|
 |
Creator of EliteSwitch
|
|
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
|
|
Re: [HELP] Parseing in vb6
Quote:
Originally Posted by dgameman1
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,..;
|

03-30-2011, 12:23 AM
|
 |
Member
|
|
Join Date: Feb 2011
Posts: 29
|
|
Re: [HELP] Parseing in vb6
He pretty much just fixed the problem for you. Another thing, why are you using vb6? Its so old.
/facepalm
__________________
Now selling CHEAP hosting! UNLIMITED SPACE for $10/month. ANYTHING IS ALLOWED.
Just drop me a PM with your email!
Vouches---
Quote:
Originally Posted by mskr93
Vouch for Hiatus.Sold him my pure acc name , trade went smooth , i went first , tyvm
|
|

06-14-2011, 06:54 AM
|
|
Newcomer
|
|
Join Date: Jun 2011
Posts: 16
|
|
Re: [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...
Last edited by _trevaSaurus : 06-14-2011 at 06:55 AM.
|
 |
|