Results 1 to 7 of 7
  1. #1
    gpeirce is offline Novice
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Location
    Oregon, USA
    Posts
    13

    Easy question about strings

    Can someone tell me the code to use to find the 8th double-quoted value in the below string? (The string will always have the // { leader. Also, it looks like the string contains carriage returns and line feeds because it comes out like this in the debug print).

    // [
    {


    "id": "22808"
    ,"t" : "MRK"
    ,"e" : "NYSE"
    ,"l" : "61.87"
    ,"l_fix" : "61.87"
    ,"l_cur" : "61.87"


    The above is the result of running the URL: strURL = "http://finance.google.com/finance/info?client=ig&q=NSE:MRK". The stock price is always the 8th item, right after the l. I don't know if you use the string command, unstring command, a "find" command, or what.

    Thank you so much.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I would probably create a function that accepted the string and a number as inputs. It would use the Split() function to put the various elements into an array, then pull out the desired value based on the number input. It would probably have to use the Mid() function to pull out whatever is after the colon. That would let you use it to pull out any of the elements.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  4. #4
    gpeirce is offline Novice
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Location
    Oregon, USA
    Posts
    13
    Thank you for asking. The whole string is below. I took Paul's idea of Split and found that array (8) will contain:

    "61.87"
    ,"l_fix"

    Now all i have to do is figure out how to isolate the 61.87.

    The full original string is:



    // [
    {
    "id": "22808"
    ,"t" : "MRK"
    ,"e" : "NYSE"
    ,"l" : "61.87"
    ,"l_fix" : "61.87"
    ,"l_cur" : "61.87"
    ,"s": "0"
    ,"ltt":"4:00PM EST"
    ,"lt" : "Nov 18, 4:00PM EST"
    ,"lt_dts" : "2016-11-18T16:00:41Z"
    ,"c" : "-0.83"
    ,"c_fix" : "-0.83"
    ,"cp" : "-1.32"
    ,"cp_fix" : "-1.32"
    ,"ccol" : "chr"
    ,"pcls_fix" : "62.7"
    }
    ]

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You must have split on the colon? I would probably have used the carriage return to keep the values together. In any case, you can try the Replace() function to get rid of the quotes and the Val() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    gpeirce is offline Novice
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Location
    Oregon, USA
    Posts
    13
    Paul, it worked great. My coding is sloppy but using the Split and the left command and the replace command it all worked. Thank you for your help!!!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Easy Question about Many to Many
    By hoodoo in forum Access
    Replies: 17
    Last Post: 09-22-2015, 10:05 AM
  2. Easy Question
    By BenjaminDz in forum Access
    Replies: 13
    Last Post: 05-06-2015, 02:58 PM
  3. Easy question
    By fyes in forum Programming
    Replies: 1
    Last Post: 12-20-2011, 12:08 AM
  4. Probably a very easy question
    By Ext1jdh in forum Queries
    Replies: 4
    Last Post: 08-02-2011, 12:26 PM
  5. Easy question
    By Danzig in forum Access
    Replies: 11
    Last Post: 10-28-2010, 06:48 PM

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