拆分字符串并输出到 MS Access 2007 中的列表框
如果我有一个文本框,其内容类似于“大棕色狐狸跳过了懒狗”, 我如何分割它并将内容放入这样的列表框中:
0,the
1,big
2,brown
3,fox
4,jumped
5,over
6,the
7,lazy
8,dog
PLz帮助,新手
if i have a textbox with contents like "the big brown fox jumped over the lazy dog",
how do i split it and put the contents in a listbox like this:
0,the
1,big
2,brown
3,fox
4,jumped
5,over
6,the
7,lazy
8,dog
PLz help, newbie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Split() 函数。像这样的事情:
现在,您需要一个定义有两列的列表框,并且您需要适当地设置这些列的宽度(如果您想同时看到两者,则 0.5";1" 可以;0";1"如果您希望隐藏第一列(尽管如果您不更改默认属性,它将是绑定列),您还需要将 RowSourceType 属性设置为“值列表”,
但需要注意的是:
有一个硬性限制。关于 Rowsource 的长度属性,当它是一个值列表时,我不记得确切的数字,但它超过 2000 个字符,如果您需要更多,那么我建议您将创建列表的代码转换为自定义函数。有关如何在组合/列表框的帮助中执行此操作的说明。
You could use the Split() function. Something like this:
Now, you'd then need a listbox defined with two columns, and you'd want to set the widths on those columns appropriately (0.5";1" works if you want to see both; 0";1" works if you want the first column to be hidden (though it will be the bound column if you don't change the default properties). You also need to set the RowSourceType property to "Value List".
One caveat:
There's a hard limit on the length of the Rowsource property when it's a Value List. I can't remember the exact number, but it's somewhere upward of 2000 characters. If you need more than that, then I'd suggest you convert the code that creates the list to a custom function. There are instructions on how to do this in the help for combo-/listboxes.