頁:
[1]
TextBox 判斷空值問題
VB2012請問 TextBox 可否再按下Button時 藉由Button按鍵 判斷它是否為空值?
判斷條件該怎麼下.....試了很久但不成功
另外 在判斷TextBox 之後 ,Button_Click 還有其他功能
但如果為空值我該怎麼讓程式停在判斷完之後
也試了很久,但程式一直往下跑
<div></div> 判斷空值 有兩種
一
字串if textbox1.text = "" then
'這邊就輸入你要執行的
end if二
任何數值if textbox1.text = nothting then
end if至於你說要停在你輸入空值的地方就像我上面寫的那種方式 OK 謝謝幫助
愛你 啾咪 哈哈{:55:} 空值的判斷有後多種,因為有時候輸入的是個空白字元,看來沒有但其實有的
可用字元長度做判斷
當字元長度為零時表示沒有輸入,否則就是有
VB.NET
String.IsNullOrEmpty(TextBox1.Text)
表示指定的字串是否為 null 或 Empty 字串。
<br><br><br><br><br><div></div> 本帖最後由 roykinglo 於 2013-10-29 10:28 PM 編輯
Class Sample
Public Shared Sub Main()
Dim s1 As String = "abcd"
Dim s2 As String = ""
Dim s3 As String = Nothing
Console.WriteLine("String s1 {0}.", Test(s1))
Console.WriteLine("String s2 {0}.", Test(s2))
Console.WriteLine("String s3 {0}.", Test(s3))
End Sub
Public Shared Function Test(s As String) As String
If String.IsNullOrEmpty(s) Then
Return "is null or empty"
Else
Return String.Format("(""{0}"") is neither null nor empty", s)
End If
End Function
End Class
' The example displays the following output:
' String s1 ("abcd") is neither null nor empty.
' String s2 is null or empty.
' String s3 is null or empty....<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div>
頁:
[1]