How to identify between ok and cancel button in inputbox

前端 未结 3 1630
情歌与酒
情歌与酒 2020-12-03 19:54

Hi Hi I have to write a code where if the user clicks enters something in the input box it should proceed further.If it doesnot enter any value it should throw back the same

3条回答
  •  一生所求
    2020-12-03 20:22

    I'm using VBS and my investigation into cancel/ok revealed the following:

    Cancel returns an empty string AND a zero length string - same thing you say?, apparently not.

    Ok returns a zero length string only.

    I use the code below to differentiate.

       if IsEmpty(nmbr)  then               'cancel button pressed ?
            nmbr = "x"  
       end if  
    
       if not IsEmpty(nmbr) then            'ok button pressed ?
          if len(nmbr) = 0 then
            nmbr = "ok"
          end if 
       end if
    

提交回复
热议问题