用户表单输入小连字符和长连字符? (✱使用 Excel 中的符号)

Userform Input Small hyphen & Long hyphen? (✱Using symbols in Excel)

我在 Excel-VBA 的用户表单中从表单的用户端输入一个字符串。我想知道如何输入长连字符。

小连字符为 Shift + - the (减号按钮下一个到 0).

当我在后端的 VBA 代码中进行字符串匹配时,您如何在表单中输入长连字符?可以用Alt+0150输入,但是还有更简单的方法吗?

如果输入长连字符的选项不起作用,那么我将在后端通过查找和替换方法或 VBA 中的其他方法处理此值。

只有一个"连字符"... =96=]ᖴᗩᗰᎥᒪƳ ᴏ͓ ᑕᕼᗩᖇᗩᑕ丅ᗴᖇᔕ 调用了 Dashes.

例子:

  • 连字符 [-] (-)

  • 减号[] (−)

  • En dash [] (–)

  • Em 破折号 [] (—)

✱ 您的浏览器可能会以不同方式呈现它们,但上面的字体 应该 [Consolas or Courier 13px] and(Arial 或 Helvetica 15px)。 虽然它们看起来都一样 in this font,但 四个不同的字符。

字符可以copy/pasted直接从这里- − – —变成Excel(但是不能到VBA编辑器), 或者可以 连同 136,686 other Unicode 个字符 , 或者:

  • 与工作表公式,使用ᴜɴɪᴄʜᴀʀ function:

    =UNICHAR(9733)  'produces a [★] star character.
    
  • 以编程方式使用 VBA,使用 ChrW function:

    Range("A1") = ChrW(9743) 'puts a wee [☏] rotary phone in cell A1.
    

有关破折号的更多信息 —


"Stealing" 来自网站的 Unicode 字符

有各种方便的 Unicode 符号 — 数量之多以至于很难找到 "just" 正确的符号。

但是您可以(并且将会!)在您想要以编程方式使用的网页上找到其他 Unicode 符号。您只需要符号的代码,即可轻松确定:

  • Copy/paste the symbol from your browser (being careful to copy only the single character; no spaces, etc.) into a cell in Excel

  • then, go to VBA's Immediate Window ( AltF11CtrlG ), type:

    MsgBox AscW([a1]) 
    

...(Where A1 is the cell with the character). Hit Enter, and the character's Unicode code will display.

您也可以使用 Windows' built-in Character Map utility, or one of many third-party browser plug-ins。您甚至可以将符号直接粘贴到 Google 以了解更多信息:


最后,如果没有以下链接,关于 Unicode 主题的讨论将是不完整的:

The Unicode Consortium (unicode.org)and,

“ȶɦɛ Ⓣⓔⓧⓣ ” (没错,那些都是纯文本个字符。)

...如果您正在寻找一份独特的礼物,或者只是想让您的名字因 真正 重要的事情而载入史册,您甚至可以 adopt a Unicode character, 100 美元起 ᴜsᴅ!


特别感谢Vinton Cerf for adopting the Unicode Leonard Nimoy's "Live Long and Prosper"符号。