VB.NET校驗字符串函數

本文給大家分享的是2個vb.net中驗字符串類型的函數,十分的簡單實用,有需要的小夥伴可以參考下。

VB.NET校驗字符串是否是日期

'Validate for a date
Shared Function checkdate(ByVal thisvalue As String) As String
  If Not IsDate(thisvalue) Then
    checkdate = "NULL"
  Else
    checkdate = "'" & thisvalue & "'"
  End If
  Return checkdate
End Function ' END checkdate

VB.NET檢查字符串是否是數字

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Used to submit values to the database, check for empty value, replace w/ "NULL"
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Shared Function checkNumber(ByVal thisvalue As String) As String
  If IsDBNull(thisvalue) Or Len(thisvalue) = 0 Or Not IsNumeric(thisvalue) Then
    checkNumber = "NULL"
  Else
    checkNumber = thisvalue
  End If
  Return checkNumber
End Function ' END checkNumber

以上所述就是本文的全部內容了,希望大家能夠喜歡。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章