以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求助大大  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=131723)

--  作者:ezilu
--  发布时间:2019/3/5 15:33:00
--  求助大大
Dim xb As String = e.Form.Controls("性别").Text
Dim nl As String = e.Form.Controls("年龄").Text
Dim pbx As WinForm.PictureBox
pbx = e.form.Controls("PictureBox1")

If xb = "男" Then
    If nl > 50 Then
        pbx.Image = GetImage("Images\\nln.png")
    ElseIf nl > 30 Then
        pbx.Image = GetImage("Images\\nzn.png")
    Else
        pbx.Image = GetImage("Images\\nqn.png")
    End If
ElseIf xb = "女" Then
    If nl > 50 Then
        pbx.Image = GetImage("Images\\nln1.png")
    ElseIf nl > 30 Then
        pbx.Image = GetImage("Images\\nzn1.png")
    Else
        pbx.Image = GetImage("Images\\nqn1.png")
    End If
Else
    pbx.Image = GetImage("Images\\none.png")
End If

把这段代码添加到姓名的valuechaned事件中  为什么无效  图片控件不显示 哪里出错了 谢谢
图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20190305153006.png
图片点击可在新窗口打开查看
[此贴子已经被作者于2019/3/5 15:33:50编辑过]

--  作者:有点甜
--  发布时间:2019/3/5 15:57:00
--  

1、你在事件里面加入msgbox,看能否弹出窗口。

 

2、valueChanged事件,是你焦点离开控件后,才会触发的。


--  作者:有点甜
--  发布时间:2019/3/5 15:59:00
--  

如果msgbox可以弹出,试试修改代码,如

 

pbx.Image = GetImage(projectPath & "Images\\nqn1.png")

 


--  作者:ezilu
--  发布时间:2019/3/5 16:42:00
--  
加了这个有显示 有变化了  
但是  我这个判断年龄语句是不是有问题,它不按年龄阶段出相应的图片

--  作者:有点甜
--  发布时间:2019/3/5 16:45:00
--  
以下是引用ezilu在2019/3/5 16:42:00的发言:
加了这个有显示 有变化了  
但是  我这个判断年龄语句是不是有问题,它不按年龄阶段出相应的图片

 

你输入姓名的时候,年龄输入了没有?如果这时年龄没有值,那你要把代码也写到年龄、性别的事件里去。

 


--  作者:ezilu
--  发布时间:2019/3/5 16:49:00
--  
是绑定字段的  都有
    If nl > 60 Then
        pbx.Image = GetImage(projectPath & "Images\\nln.png")
    ElseIf nl > 40 Then
        pbx.Image = GetImage(projectPath & "Images\\nzn.png")
    Else
        pbx.Image = GetImage(projectPath & "Images\\nqn.png")
    End If

我这个判断逻辑有错吗?

--  作者:ezilu
--  发布时间:2019/3/5 17:01:00
--  
是绑定字段的  都有



    If nl > 60 Then
        pbx.Image = GetImage(projectPath & "Images\\nln.png")
    ElseIf nl > 40 Then
        pbx.Image = GetImage(projectPath & "Images\\nzn.png")
    Else
        pbx.Image = GetImage(projectPath & "Images\\nqn.png")
    End If

我这个判断逻辑有错吗?

--  作者:有点甜
--  发布时间:2019/3/5 17:06:00
--  

加入代码,如

 

msgbox(nl)

 

看弹出什么值


--  作者:ezilu
--  发布时间:2019/3/5 17:07:00
--  
弹出的值 不按年龄 性别逻辑
感觉随便出的
呵呵

--  作者:有点甜
--  发布时间:2019/3/5 17:09:00
--  

 

做个例子发上来测试。