|
-
Aug 18th, 2005, 11:59 PM
#1
Thread Starter
Member
Try and Spot The Error! I can't :(
What this does is it goes through the array "items" and if in the current element contains what is contained in the variable item, then it parses it down. Now it worked earlier when Item was a variable, but rather a set value, but now it doesn't. Can you spot the error?
VB Code:
Private Function GetItems(Item As String)
Dim items() As String
Dim H As Integer
MsgBox Item
Item = Parse(HTML, "' onClick=""", "(you can still haggle to push the price lower!)') ) { return false; }""", True)
items() = Split(Item, vbCrLf)
For H = 0 To UBound(items)
MsgBox items(H)
If InStr(1, items(H), Item, vbTextCompare) Then
URL = Between(items(H), "this.href='", "'; if ( !confirm('Are you sure you wish to purchase")
MsgBox URL
Exit Function
End If
Next H
End Function
Many thanks!
-
Aug 19th, 2005, 12:06 AM
#2
Hyperactive Member
Re: Try and Spot The Error! I can't :(
someone likes neopets...
You do realize some of your single quotes should be double.... your commenting out your own code.
-
Aug 19th, 2005, 12:08 AM
#3
Thread Starter
Member
Re: Try and Spot The Error! I can't :(
Meh. It's taught me a lot making programs for neopets. And it just appears that they are comments because of the board, javascript uses single quotes.
-
Aug 19th, 2005, 12:27 AM
#4
Re: Try and Spot The Error! I can't :(
Is this VB? What is the PARSE function?
-
Aug 19th, 2005, 12:30 AM
#5
Hyperactive Member
Re: Try and Spot The Error! I can't :(
He wrote the parse somewhere else in his code.
His problem is in the line:
If InStr(1, items(H), Item, vbTextCompare) Then
-
Aug 19th, 2005, 12:31 AM
#6
Thread Starter
Member
Re: Try and Spot The Error! I can't :(
The parse function is:
VB Code:
Public Function Parse(Source As String, Starting As String, Ending As String, Multi As Boolean) As String
Dim strData As String
strData = Source
Dim iStart As Long
Dim iEnd As Long
Dim sTemp As String
Dim sText() As String
Length = Len(Starting)
If Length = 0 Then
MsgBox "Error: No String found", vbCritical, "Error"
Exit Function
End If
If Multi = True Then
iStart = 1
Do Until InStr(iStart, strData, Starting, vbTextCompare) = 0
iStart = InStr(iStart, strData, Starting, vbTextCompare) + Length
iEnd = InStr(iStart, strData, Ending, vbTextCompare)
sTemp = sTemp & Mid$(strData, iStart, iEnd - iStart) & vbCrLf
Loop
sTemp = Left$(sTemp, Len(sTemp) - 2)
sText = Split(sTemp, vbCrLf)
Parse = sTemp
Exit Function
ElseIf Multi = False Then
iStart = InStr(1, strData, Starting, vbTextCompare) + Length
iEnd = InStr(iStart, strData, Ending, vbTextCompare)
strText = Mid$(strData, iStart, iEnd - iStart)
If strText = vbNullString Then
MsgBox "Error: No string found", vbCritical, "Error"
Exit Function
End If
Parse = strText
End If
End Function
-
Aug 19th, 2005, 01:05 AM
#7
Re: Try and Spot The Error! I can't :(
 Originally Posted by mstic
He wrote the parse somewhere else in his code.
His problem is in the line:
If InStr(1, items(H), Item, vbTextCompare) Then
Item is the full document. It cannot be the string2
String2 should be something that you want to find in each of the split lines.
InStr([start, ]string1, string2[, compare])
The InStr function syntax has thesearguments:
Part Description
start Optional.Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start containsNull, an error occurs. The start argument is required if compare is specified.
string1 Required.String expression being searched.
string2 Required. String expression sought.
compare Optional. Specifies the type ofstring comparison. If compare is Null, an error occurs. If compare is omitted, the Option Compare setting determines the type of comparison.
-
Aug 19th, 2005, 01:18 AM
#8
Re: Try and Spot The Error! I can't :(
 Originally Posted by mstic
You do realize some of your single quotes should be double.... your commenting out your own code.
Not the case, since the aproprostrophes are inside double quote marks. Symbols within string literals are not processed.
-
Aug 19th, 2005, 01:54 AM
#9
Frenzied Member
Re: Try and Spot The Error! I can't :(
Aint u missing something here?
!confirm('Are you sure you wish to purchase") <-- shouldn't that be '") instead of ") ?
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
|