只允許輸入數字的多種表現形式....
程序中,我們經常用到只需要輸入數字的地方..
示例1:用數組來實現
(VB.Net 部分)
Private istg_char() As Char = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} ' 定義一個數組
Dim istg_check_char as string
istg_check_char=Text1.Text.Trim(Me.istg_char)
If istg_check_char="" then
Messagebox.show("為數字型")
else
Messagebox.show("為字符串")
End If
(C# 部分)
char[] number=new char(10){'0','1','2','3','4','5','6','7','8','9'};
strng check=textbox1.text.trim(number);
if(check= ="")
{
MessageBox.Show("為數字型");
}
Else
{
Messagebox.show("為字符串");
}