VBA获取Combobox以“建议”一个选项 [英] VBA Get Combobox to 'suggest' an option

查看:1025
本文介绍了VBA获取Combobox以“建议”一个选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在写一个验证单词的伪拼写检查器反对列表。未知单词显示在文本框中,允许单词列表位于下面的组合框中。我想要组合框提出一个建议基于未知的单词。即未知词是挖掘,组合框中允许的词之一是挖掘。我想要组合框建议挖掘一词。我的问题是自动完成功能不提供建议,因为未知字词比允许的字词长。



我的解决问题的想法是执行以下操作:
- 将未知单词解析为字符数组。
- 将一次一个字符添加到组合框文本属性,并允许自动完成运行。
- 只要自动完成功能停止工作,请删除一个字符并插入自动完成建议的字词。



我的问题是我找不到任何东西告诉我一次自动完成已停止工作。



任何想法,建议或替代方法欢迎。

/ p>

解决方案

您可能想更改ComboBox的2个属性选择从列表强制输入条目:


  1. MatchEntry - > 1 - fmMatchEntryComplete

  2. MatchRequired - > True

因此,当用户尝试在列表外选择一个单词时,会得到一个 :




< img src =https://i.stack.imgur.com/7jI2o.pngalt =输入图片说明here>>


I am relatively new to VBA and I am trying to solve a problem working with a userform in Excel 2010.

I am writing a pseudo spell checker that validates words against a list. The unknown word is presented in a text box and the list of allowed words is in a combo box below. I would like the combo box to present a 'suggestion' based on the unknown word. i.e. the unknown word is "Excavation" and one of the allowed words in the combo box is "Excavate". I would like the combo box to suggest the term "Excavate". My problem is that autocomplete doesn't offer a suggestion because the unknown word is longer than the allowed word.

My thought on solving the problem is to do the following: - Parse the unknown word into a character array. - Add the characters one at a time to the combo box text property and allow autocomplete to run. - As soon as autocomplete stops working, remove one character and insert the word that autocomplete suggests.

My problem is I cannot find anything to tell me once auto complete has stopped working.

Any thoughts, suggestions, or alternate approaches welcome.

Thanks in advance,

Will

解决方案

You may want to change 2 properties for the ComboBox to force an entry from a list is selected:

  1. MatchEntry --> 1 - fmMatchEntryComplete
  2. MatchRequired --> True

So when a user try to select a word outside of the list, they get a "Invalid property value.":

这篇关于VBA获取Combobox以“建议”一个选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆