VB common functions collection [11.15 update ...]

xiaoxiao2021-03-06  38

Remove all HTML tags

Function FilterHTML (STR, STRLEN) DIM RE RE RE RE = new regexp Re.ignorecase = true re.global = true rue re.pattern = "<(. [^>] *)>" Str = re.replace (str, " ) Set re = nothing DIM L, T, C, I L = LEN (STR) T = 0 for i = 1 to l C = ABS (ASC (MID (STR, I, 1))) IF C> 255 THEN T = T 2 else t = t 1 end if if t> = strlen damtr = Left (STR, I) & "..." exit for else cutstr = Str End if Next Cutstr = Replace (Cutstr, CHR (10 ), "") Cutstr = Replace (Cutstr, Chr (13), "") end function

Judging whether the string is legal email

Public Function IsValidemail (Stremail As String) AS Booleandim Names, Name, I, CISVALIDEMAIL = True Names = Split (stremail, "@")

IF Ubound (Names) <> 1 Then IsValidemail = false exit functionendiff

For Each Name in Names

IF len (name) <= 0 dam isvalidemail = false exit function endiff

For i = 1 to Len (Name) C = LCase (MID (Name, I, 1)) IF INSTR ("AbcdefghijklmnopqrStuvwxyz_-.", C) <= 0 and not isnumeric (c) Then isvalidemail = false exit function endiff NEXT

IF LEFT (Name, 1) = "." Or right (name, 1) = "." "The isvalidemail = false exit function endiff

NEXT

IF INSTR (Names (1), ".") <= 0 Then IsValideMail = false exit functionendiff

I = LEN (Names (1)) - Instrrev (Names (1), ".")

I <> 2 and i <> 3 Then IsValidemail = false exit functionendiff

If INSTR (streamail, ".")> 0 Then isvalidemail = false exit functionendiff

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-75904.html

New Post(0)