Results 1 to 3 of 3
  1. #1
    ThatWumboGuy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    1

    Compile error: Expected: list separator or )

    Hi,
    When I try to execute this function in MS Excel I get the error in the title. Any ideas how to fix it?
    Here is my code:

    Funcion GetData(sName as String, sItem as String, sURL = "http://api.eve-central.com/api/marketstat?typeid=" & sItem & "&usesystem=30000142")

    Dim oHttp As New MSXML2.XMLHTTP60
    Dim xmlResp As MXSML2.DOMDocument60
    Dim result As Variant
    On Error GoTo EH

    If sURL = "" Then
    sURL = "http://api.eve-central.com/api/marketstat?typeid=" & sItem & "&usesystem=30000142"
    End If

    'open the request and sent it
    oHttp.Open "GET", sURL & sName, False
    oHttp.Send

    'get the response as xml
    Set xmlResp = oHttp.responseXML

    'get Item


    GetData = xmlResp.getElementsByTagName(sItem).Item(0).Text

    'Examine output of these in the Immediate window
    Debug.Print sName
    Debug.Print xmlResp.XML

    CleanUp:
    On Error Resume Next
    Set smlResp = Nothing
    Set oHttp = Nothing
    Exit Function
    EH:
    GetData = CVErr(xlErrValue)
    GoToCleanUp

    End Function

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Don't know what you are doing, but there were a few errors I corrected.

    Funcion GetData(.......
    "Function" is misspelled


    GoToCleanUp
    Using "Goto" is poor programming practice - generally leads to spaghetti code
    In error handler use "Resume CleanUp"

    Here are the changes I made to the code:
    Code:
    Function GetData(sName As String, sItem As String)
    
       Dim oHttp As New MSXML2.XMLHTTP60
       Dim xmlResp As MXSML2.DOMDocument60
       Dim result As Variant
       Dim sURL As String
    
       On Error GoTo EH
    
       'If sURL = "" Then
       sURL = "http://api.eve-central.com/api/marketstat?typeid=" & sItem & "&usesystem=30000142"
       'End If
    
       'open the request and sent it
       Debug.Print sURL & sName    ' <<--- is this correct?? Should there be a comma or a space before sName???
       oHttp.Open "GET", sURL & sName, False
       oHttp.Send
    
       'get the response as xml
       Set xmlResp = oHttp.responseXML
    
       'get Item
       GetData = xmlResp.getElementsByTagName(sItem).Item(0).Text
    
       'Examine output of these in the Immediate window
       Debug.Print sName
       Debug.Print xmlResp.XML
    
    CleanUp:
       On Error Resume Next
       Set smlResp = Nothing
       Set oHttp = Nothing
       Exit Function
    
    EH:
       GetData = CVErr(xlErrValue)
       'GoToCleanUp
       Resume CleanUp
    
    End Function

  3. #3
    vincent-leeway is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    36
    Yes indeed misspelling of function is some thing which strikes first and I think this would only be the source of error. Go to is a poor programming practice but does not generates error if put correctly but yes it does make code unreadable and complicated.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-23-2012, 11:59 PM
  2. Compile Error: Expected: list separator or )
    By Kirsti in forum Programming
    Replies: 2
    Last Post: 03-27-2012, 02:52 PM
  3. Replies: 6
    Last Post: 11-24-2011, 08:38 PM
  4. Replies: 8
    Last Post: 01-19-2011, 04:48 AM
  5. compile error: expected end of statement
    By RedGoneWILD in forum Programming
    Replies: 5
    Last Post: 07-29-2010, 10:12 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums