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!
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.
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.
Re: Try and Spot The Error! I can't :(
Is this VB? What is the PARSE function?
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
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
Re: Try and Spot The Error! I can't :(
Quote:
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.
Quote:
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.
Re: Try and Spot The Error! I can't :(
Quote:
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.
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 ") ?