英文:
Excel VBA How to break up very long URL for readability?
问题
在VBA中,我正在将一个URL传递给Google地图。在URL中添加多个标记后,字符串变得非常长且难以阅读。
我想为每个标记在URL中使用单独的行以提高可读性。
VBA会出现问题,用于代码的换行符(空格下划线)无法通过VBA编译器传递。HTML换行符也不起作用。
示例:bot.Get "https://maps.googleapis.com/maps/api/etc etc etc"
感谢您的关注。
英文:
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.
答案1
得分: 1
以下示例说明了如何将长字符串跨多行拆分:
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"
请注意,每行都有双引号、和号和下划线,除了最后一行。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论