回 帖 发 新 帖 刷新版面

主题:新手编程问题!急!!!

各位大虾,小弟刚开始自学POWERBUILDER 不久,编了个东西,就是不能运行,郁闷啊...请各位大虾指点迷津!谢了...
  
string inf = ""
if rb_sex_boy.checked then
    st_sex.text = rb_sex_boy.text
else
    st_sex.text = rb_sex_girl.text
    
end if

if cbx_1.checked then
    inf += ", " + cbx_1.text
if cbx_2.checked then
    inf += ", " + cbx_2.text
if cbx_3.checked then
    inf += ", " + cbx_3.text
if cbx_4.checked then
    inf += ", " + cbx_4.text
if inf = "" then 
    st_inf.text = "<你还没有作选择>"
else 
    st_inf.text = right(inf,len(inf) - 1)
end if

回复列表 (共4个回复)

沙发

你要达到什么目的呀?

板凳

if cbx_1.checked then
    inf += ", " + cbx_1.text
if cbx_2.checked then
    inf += ", " + cbx_2.text
if cbx_3.checked then
    inf += ", " + cbx_3.text
if cbx_4.checked then
    inf += ", " + cbx_4.text
if inf = "" then 
    st_inf.text = "<你还没有作选择>"
else 
    st_inf.text = right(inf,len(inf) - 1)
end if 

有些if要改成elseif吧.

3 楼

就是,要不然你就每个IF……THEN……END IF配对完整,或者不要用换行的方式,如:
if cbx_1.checked then inf += ", " + cbx_1.text
if cbx_2.checked then inf += ", " + cbx_2.text
if cbx_3.checked then inf += ", " + cbx_3.text
if cbx_4.checked then inf += ", " + cbx_4.text

if inf = "" then
    st_inf.text = "<你还没有作选择>"
else 
    st_inf.text = right(inf,len(inf) - 1)
end if 

 // 最后一个IF语句也可以用如下的方法
if len(trim(inf)) > 0 then
    st_inf.text = right(inf, len(inf) - 1)
else
    st_inf.text = "<你还没有作选择>"
end if

4 楼

楼上所说的解决办法是可以达到目的,但是那样无形中就牺牲了系统的运行速度呀

我来回复

您尚未登录,请登录后再回复。点此登录或注册