简体   繁体   中英

VB6 - comboboxes lost focus

I'm working on a VB6 project and I cam across something that I'm unable to resolve. In my project I'm using 2.0 comboboxes. Everything works fine, in terms of loading the combobox with data, selecting it, and the whole bunch. What I'm trying to do is, once data has been selected, I'm making sure that the same data has not been selected in both comboboxes. I'm trying to write a quick comparison IF statement in LOST FOCUS for one of the cbo's but it doesn't seem to work.

Private Sub cbo1_LostFocus() 
if cbo1.text<>"" and cbo2.text<>"" then
    if cbo1.text = cbo2.text then
        MSGBOX "Duplicate Values"
    else
        exit sub
    End if
end if
End Sub

it doesn't at all realize there is LOST FOCUS - I don't think I've ever done that to a cbo, usually textboxes and such. Any help is appreciated.

You could try GotFocus instead. It seems the LostFoucs event can be overridden or masked in certain cases. This article shows a similar problem: http://www.vbforums.com/showthread.php?396536-RESOLVED-VB6-LostFocus

Of course, you could always upgrade to the latest VB, but I'm guessing you have your reasons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM