多命令按钮的处理程序,使代码更短 [英] Handler for multi Command Button, to make the code shorter

查看:62
本文介绍了多命令按钮的处理程序,使代码更短的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好......

我有27个命令按钮(它是字母表)来获取基于第一个字母的员工姓名并将其显示在列表框上。

实际上我知道怎么做,但是代码太长了。

可能有人在这里可以帮助我缩短代码。代码如下:

Hi All...
I have 27 command buttons (it''s alphabet) to get Employee Name based on First Letter and to display it on List Box.
Actually i got how to do it, but the code would be too long.
Could be somebody here can help me to make the code shorter. The code is like below:

展开 | 选择 | Wrap | 行号

推荐答案

您可以将按钮代码转换为一个函数,在每个按钮下单击,添加一个全局变量,将该全局变量设置为要在SELECT语句中搜索的字母,并将SELECT语句中的当前字母替换为您指定的全局变量。


功能代码:
You could turn your button code into a function and under each button click, add a global variable, set that global variable to the letter you want to be search in your SELECT statement, and replace the current letter within the SELECT statement with the global variable that you specified.

Function Code:
展开 | 选择 | Wrap | 行号


感谢Luk3r,它对我很有帮助。
Thanks Luk3r, it''s help me.


升级了一个小位:
upgraded a lil bit:
展开 | 选择 | Wrap | 行号


这篇关于多命令按钮的处理程序,使代码更短的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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