[.NET] 在groupbox裡如何同時驗證多個textbox렠…
請輸入專案類型(網站專案或者應用程式專案):
Visual Studio c++ Windows application form
在button click按下時同時檢驗多個textbox裡的值是否在驗證範圍內?
目前單一個textbox是用以下:
Regex ^reg = gcnew Regex("[a-fA-f0-9]");
MatchCollection ^match = reg->Matches(textBox1->Text);
if((textBox1->TextLength < 2) || (textBox1->TextLength == 0)) {
MessageBox::Show("\nPlease input 2 number !!", "Warning",
MessageBoxButtons::OK);
return;
}
if(match->Count < 2) {
MessageBox::Show("\nInput number must between 0 ~ f ", "Warning",
MessageBoxButtons::OK);
textBox1->Text = "";
return;
}
如果要同時檢驗多個,照目前方法比需宣告多個match,並在if中以多個||條件式判斷
ex: if(a||b||c||d||e..),有更簡潔的作法嗎? thanks
如果用groupbox將需驗證的textbox包起來,能否用迴圈的方式控制groupbox裡
textbox的值來作條件判斷?
ex: for(i=0 ; i<5 ; i++) {
if(groupbox->item[i]->Text).......
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.205.253
※ 編輯: deh3215 來自: 114.43.205.253 (08/08 00:35)
→
08/08 11:18, , 1F
08/08 11:18, 1F
→
08/08 11:20, , 2F
08/08 11:20, 2F
→
08/08 11:20, , 3F
08/08 11:20, 3F
→
08/08 11:21, , 4F
08/08 11:21, 4F
→
08/08 11:22, , 5F
08/08 11:22, 5F
→
08/08 11:23, , 6F
08/08 11:23, 6F
→
08/08 12:49, , 7F
08/08 12:49, 7F
→
08/08 13:58, , 8F
08/08 13:58, 8F
推
08/08 20:46, , 9F
08/08 20:46, 9F
→
08/08 22:33, , 10F
08/08 22:33, 10F
→
08/08 22:33, , 11F
08/08 22:33, 11F
推
08/09 00:35, , 12F
08/09 00:35, 12F