以文本方式查看主题

-  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=158802)

--  作者:flashv
--  发布时间:2020/12/3 2:27:00
--  关于"回车键按下"的问题

图片点击可在新窗口打开查看此主题相关图片如下:2020-12-03 02-25-00.jpg
图片点击可在新窗口打开查看


如上图.代码如下

If e.KeyCode = Keys.Enter Then
    Dim b1 As WinForm.Button = e.Form.Controls("Button1")
    b1.PerformClick
    msgbox("我是提示内容")
End If

按钮代码并未执行.

--  作者:有点蓝
--  发布时间:2020/12/3 9:35:00
--  
那个弹出提示,按钮代码肯定执行了。如果没有效果,应该是代码里的各种判断条件不符合
--  作者:flashv
--  发布时间:2020/12/3 13:17:00
--  
代码没有执行,MSGBOX就是为了测试代码执行到哪里的.
Button1就是"查询"按钮.单击查询按钮或是用其他方法调用都没有问题.
比如我在文本框2的单击事件中测试以下代码
Dim b1 As WinForm.Button = e.Form.Controls("Button1")
b1.PerformClick
结果是正确的.正常执行了查询按钮中的代码.

--  作者:有点蓝
--  发布时间:2020/12/3 13:46:00
--  
能够弹出提示,按钮代码肯定执行了。按钮代码发上来看看
--  作者:flashv
--  发布时间:2020/12/3 13:58:00
--  
Dim cdex As String

With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If cdex > "" Then
            cdex = cdex & " And "
        End If
        cdex = cdex & "商品条码 Like \'*" & .Value & "*\'"
    End If
End With

With e.Form.Controls("TextBox2")
    If .Value IsNot Nothing Then
        If cdex > "" Then
            cdex = cdex & " And "
        End If
        cdex = cdex & "商品名称 Like \'*" & .Value & "*\'"
    End If
End With

If cdex > "" Then
    Tables("商品资料").Filter = cdex
End If

--  作者:flashv
--  发布时间:2020/12/3 14:01:00
--  
这是"查询"(Button1)按钮代码.
按钮单击,代码执行是正确的.

--  作者:有点蓝
--  发布时间:2020/12/3 14:12:00
--  
1楼的代码在什么事件里?

下面代码能不能弹出提示?
Dim cdex As String
msgbox(1)
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If cdex > "" Then
            cdex = cdex & " And "
        End If
        cdex = cdex & "商品条码 Like \'*" & .Value & "*\'"
    End If
End With

With e.Form.Controls("TextBox2")
    If .Value IsNot Nothing Then
        If cdex > "" Then
            cdex = cdex & " And "
        End If
        cdex = cdex & "商品名称 Like \'*" & .Value & "*\'"
    End If
End With
msgbox("cdex =" & cdex )
If cdex > "" Then
    Tables("商品资料").Filter = cdex
End If

--  作者:flashv
--  发布时间:2020/12/3 14:20:00
--  

文本框的,KeyDown 事件, cdex=

单击按钮,cdex = 商品条码 Like "1233"



--  作者:flashv
--  发布时间:2020/12/3 14:22:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:2020-12-03 14-14-24.jpg
图片点击可在新窗口打开查看
上图,单击按钮显示的结果.

图片点击可在新窗口打开查看此主题相关图片如下:2020-12-03 14-21-29.jpg
图片点击可在新窗口打开查看
上图,文本框KeyDown显示的结果


--  作者:有点蓝
--  发布时间:2020/12/3 14:23:00
--  
选中这个文本框,按回车,能不能弹出提示?