Excel VBA如何拆分非常长的URL以提高可读性?

huangapple go评论89阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年7月7日 02:12:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76631518.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定