asp.net 按字节检查包含全半角的文字
程序员文章站
2024-03-31 20:26:10
'''------------------------------------------------------------------------ '''
'''------------------------------------------------------------------------
''' <summary>
''' 文字列長检查(按字节检查)
''' </summary>
''' <param name="argstrcontrol">文字列</param>
''' <param name="arglength">文字列長</param>
''' <returns>true - , false - </returns>
''' <remarks></remarks>
'''------------------------------------------------------------------------
public shared function checkcontrollength(byval argstrcontrol as string, _
optional byval arglength as integer = 0) as boolean
'null
if string.isnullorempty(argstrcontrol) then
return true
end if
'文字列長
dim ilength as integer = 0
ilength = pencoding.getbytes(argstrcontrol).length()
'文字列長检查
if arglength < ilength then
return false
end if
return true
end function
''' <summary>
''' 文字列長检查(按字节检查)
''' </summary>
''' <param name="argstrcontrol">文字列</param>
''' <param name="arglength">文字列長</param>
''' <returns>true - , false - </returns>
''' <remarks></remarks>
'''------------------------------------------------------------------------
public shared function checkcontrollength(byval argstrcontrol as string, _
optional byval arglength as integer = 0) as boolean
'null
if string.isnullorempty(argstrcontrol) then
return true
end if
'文字列長
dim ilength as integer = 0
ilength = pencoding.getbytes(argstrcontrol).length()
'文字列長检查
if arglength < ilength then
return false
end if
return true
end function