1
我正在使用一個按鈕單擊一個輸入框來存儲一個值並對其執行一些驗證。我的問題是點擊取消按鈕它不會關閉,而是彈出信息的空檢查。任何幫助表示讚賞。謝謝輸入框中的取消按鈕沒有關閉
對於空檢查它彈出「請輸入一個值,然後再試一次」。
問題是,即使我點擊取消它顯示相同的消息,如「請輸入一個值,然後再試一次」,當我不提供任何值,並點擊確定它顯示相同的消息「請輸入一個值,然後再試一次「
procedure TForm1.Button1Click(Sender: TObject);
var inputValue:string;
begin
repeat
inputValue:=InputBox('Enter a value', 'value','');
if (inputValue<>'') then
begin
if MessageDlg('Do You want to enter this value ' +inputValue+'?',mtInformation,[mbYes,mbNo],0)= mrYes then
MessageDlg('Your Value got stored', mtInformation,[mbOk],0)
end;
until(inputValue='');
repeat
if (inputValue = '') then
MessageDlg('Please Enter a value and try again', mtInformation,[mbOk],0) ;
inputValue:=InputBox('Enter a value', 'value','');
if (inputValue<>'') then
begin
if MessageDlg('Do You want to enter this value ' +inputValue+'?',mtInformation,[mbYes,mbNo],0)= mrYes then
MessageDlg('Your Value got stored', mtInformation,[mbOk],0)
end;
until (inputValue<>'') ;
end;
我做了一個小編輯格式化代碼一點,但它仍然是接近不可讀。請你可以通過編輯來解決這個問題。還請說清楚「彈出信息用於空檢查」的含義。 –
感謝您的編輯。請你也可以用可讀的方式格式化代碼。我們真的需要看到它嗎?僅僅顯示一個重複塊是不夠的?請多花點時間製作問題。 –
爲了避免在剩餘的日子中輸入值,您可以考慮使用[間斷程序](http://docwiki.embarcadero.com/Libraries/XE8/en/System.Break)退出重複'當你的某些條件得到滿足時循環 – fantaghirocco