0

In VBA, I am passing a URL to Google Maps. After adding multiple Markers to the URL, the string becomes very very long and difficult to read. I would like to break up the URL with a separate line for each Marker for readability. VBA throws a hissy fit, the line break used for code (space underscore) does not get passed by the VBA compiler. HTML line breaks don't work either. Example: bot.Get "https://maps.googleapis.com/maps/api/etc etc etc"

Thank you for looking.

dlowrey
  • 35
  • 3
  • Its a little unclear what you are asking. I assume that you are trying to build a URL but you could be parsing one. Adding your code would help bring context to your question. – TinMan Jul 06 '23 at 18:24
  • 1
    Did you also include an ampersand on each line? Like this `& _` (ampersand space underscore)? – Brian M Stafford Jul 06 '23 at 18:33
  • 2
    Possible [duplicate](https://stackoverflow.com/a/16636413/4717755)? – PeterT Jul 06 '23 at 18:34
  • Aside from visually splitting the lines using line-breaks. You could also assemble the string by creating an array of strings, each item in the array being one part of the url, and then use `Join(myArray, "")`. This would let you work on each part of the url independently, before cleanly assembling the url for output. – Toddleson Jul 06 '23 at 18:38
  • The code is simple. The problem is getting a line break in the URL for readability. – dlowrey Jul 06 '23 at 19:18

1 Answers1

1

The following illustrates the idea of breaking long strings across multiple lines:

bot.Get "maps.googleapis.com/maps/api/…" & _
        "markers=color:blue%7Clabel:S%7C62.107733,-145.541936" & _
        "markers=size:tiny%7Ccolor:green%7CDelta+Junction,AK" & _
        "markers=size:mid%7Ccolor:0xFFFF00%7Clabel:C%7CTok,AK" & _
        "key=AIzaSyAhJIqOH3CNov_uZY2zPyqPBBrxorx2RN8"

Note that every line has double quotes, ampersands, and underscores. Well, except for the last line.

Brian M Stafford
  • 8,483
  • 2
  • 16
  • 25