簡體   English   中英

如何檢查是否在InputBox中按下了“取消”按鈕或“確定”按鈕

[英]How to check if Cancel button or OK button is pressed in InputBox

string input = Microsoft.VisualBasic.Interaction.InputBox("To change your email, enter it below. The current email on file is " + ParseUser.CurrentUser.Email, "Change Email", "New Email", -1, -1);

給定上面的代碼,如何檢查取消按鈕或確定按鈕是否被按下? 如果用戶按OK,我想運行一個方法。 如果他們按“取消”,那么我將不會運行該方法。

檢查字符串是否為0個字符長不會這樣做,因為即使用戶開始鍵入並按“取消”,我仍然不希望該方法運行。

如果檢查0個字符不足以判斷是否單擊了取消,那么您將需要構建自己的對話框來代替InputBox。

var answer = confirm('Are You Sure');
if (answer) {
   //...
} else {
   //...
}


//answer will be true here`enter code here`

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM