正宗菜鸟问题:if..then ..(10分)

  • 主题发起人 主题发起人 wohoot
  • 开始时间 开始时间
W

wohoot

Unregistered / Unconfirmed
GUEST, unregistred user!
if combobox1.Text='1' then memo1.Text:='a';
if combobox1.Text='5' then memo1.Text:='f';
if combobox1.Text='7' then memo1.Text:='y';
if combobox1.Text='20' then memo1.Text:='r';
if combobox1.Text='...' then memo1.Text:='....';
请问代码怎么样简单点?不要笑,我才学基础知识
 
memo1.Text:= chr(strtoint(combobox1.Text)+$60);

$61=十进制的97 真好事"a"的byte值
 
我的意思是combobox1.text中数字和mome1.text中的字母也可能是多个,如:
if combobox1.Text='19999' then memo1.Text:='a';
if combobox1.Text='1' then memo1.Text:='abfrtyty';
 
两边每对应规律??? 没规律的话,只有 if then 了,
程序嘛就是通过规律才能简化,没规律怎么简化?
 
有规律的话,就按照规律进行简化,没有规律的话是很难简化的。
如果没有规律的话:
1.使用 Case StrToInt(combobox1.Text) of 来处理;
2.把 '19999' 到 'a' 的对应关系预存到 TStrings 里面,查找的时候用
TStrings.Values['19999'] 来获得对应的值。
 
同意樓上的,先找規律
 
没有规律不成方圆!先要找到Combox和Memo内容之间的联系,有了关系还怕映射写不出吗?
 
没有规律不成方圆!
 
多人接受答案了。
 
后退
顶部