钱财随缘 發表於 2015-5-19 15:07:49

VB.NET校验字符串函数

<p><strong>VB.NET校验字符串是否是日期</strong></p>
<div class="jb51code">
<pre class="brush:vb;">
'Validate for a date
Shared Function checkdate(ByVal thisvalue As String) As String
If Not IsDate(thisvalue) Then
    checkdate = "NULL"
Else
    checkdate = "'" &amp; thisvalue &amp; "'"
End If
Return checkdate
End Function ' END checkdate

</pre>
</div>
<p><strong>VB.NET检查字符串是否是数字</strong></p>
<div class="jb51code">
<pre class="brush:vb;">
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'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

</pre>
</div>
<p>以上所述就是本文的全部内容了,希望大家能够喜欢。</p>
                           
                            <div class="art_xg">
                              <b>您可能感兴趣的文章:</b><ul><li>VB.net 查询获取数据库数据信息</li><li>C#/VB.NET 在PDF中添加文件包(Portfolio)的方法</li><li>vb.net操作注册表的方法分析【增加,修改,删除,查询】</li><li>VB.NET调用MySQL存储过程并获得返回值的方法</li><li>在VB.NET应用中使用MySQL的方法</li><li>VB.NET获取文件默认图标的方法</li><li>C#、vb.net及SQL判断指定年份是否为闰年的方法</li><li>C#中的除法运算符与VB.NET中的除法运算符</li><li>浅谈如何使用vb.net从数据库中提取数据</li></ul>
                            </div>

                        </div>
                        <!--endmain-->
頁: [1]
查看完整版本: VB.NET校验字符串函数