C�c H�m Ki?m Tra Bi?n

Sau ?�y l� c�c h�m ki?m tra bi?n


IsArray

IsArray tr? gi� tr? Boolean(True or False) khi bi?n l� m?t m?ng. C� ph�p c?a IsArray nh? sau:

IsArray(t�n bi?n)

??i s? t�n bi?n c� th? l� m?t bi?n b?t k?. IsArray tr? k?t qu? True (?�ng) n?u bi?n l� m?t m?ng(array), ng??c l?i IsArray cho k?t qu? False(sai. H�m IsArray ??c bi?t ti?n l?i v?i c�c bi?n th? (variants) ch?a m?ng.


IsDate

IsDate tr? gi� tr? Boolean khi bi?u th?c c� th? ???c chuy?n ??i sang d?ng Date(ng�y th�ng n?m). C� ph�p c?a H�m IsDate nh? sau:

IsDate(Bi?u th?c)

??i s? c?a bi?u th?c c� th? l� ng�y th�ng n?m b?t k? ho?c l� bi?u th?c chu?i m� VBScript h?p l? theo ng�y th�ng n?m ho?c th?i gian m� ng�n ng? n�y quy ??nh. IsDate tr? k?t qu? True n?u bi?u th?c l� Ng�y Th�ng N?m(Date) ho?c c� th? chuy?n ??i th�nh ng�y th�ng n?m h?p l?. N?u bi?u th?c kh�ng ph?i l� ng�y th�ng n?m ho?c ng�y th�ng n?m h?p l?, h�m s? tr? k?t qu? False. Trong Micrisoft, ng�y h?p l? l� January 01, 100 AD ??n december 31,9999.

M?t v�i v� d?:

<%
document.write(IsDate("April 22, 1947") & "
")
document.write(IsDate(#11/11/01#) & "
")
document.write(IsDate("#11/11/01#") & "<br>")
document.write(IsDate("Hello World!"))
%>


K?t qu?:

True
True
False
False

Hai bi?u th?c ??u ?�ng v� 2 bi?u th?c sau sai v� H�m IsDate nh?n th?y r?ng c�c gi� tr? trong bi?u th?c n�y kh�ng h?p l?.


IsEmpty

IsEmpty tr? gi� tr? Boolean khi m?t bi?n ???c kh?i t?o.(ch?a gi� tr? r?ng). H�m n�y r?t h?u �ch trong vi?c ki?m tra Login c?a User ho?c ki?m tra gi� tr? trong Request.QueryString.

C� ph�p c?a IsEmpty:

IsEmpty(Bi?u th?c)

??i s? c?a bi?u th?c c� th? l� m?t bi?u th?c b?t k?. Tuy nhi�n, v� IsEmpty x�c ??nh r?ng c�c bi?n c� nh�n ???c kh?i t?o hay kh�ng, n�n ??i s? c?a bi?u th?c th??ng l� m?t bi?n ??n. H�m IsEmpty tr? k?t qu? True n?u bi?n kh�ng kh?i t?o ho?c bi?n r?ng. Ng??c l?i h�m IsEmpty tr? k?t qu? False.

Xem V� d?:

<%
Dim LoginID, NoLogin
LoginID = Request.Form("loginid")
NoLogin = IsEmpty(LoginID)
If NoLogin = True Then
response.write "You must login to view this content!"
End If
%>

<%
Dim intPageNumber, intPageEmpty
intPageNumber = Request.Querystring("p")
intPageEmpty = IsEmpty(intPageNumber)
If intPageEmpty = True Then
Response.Write "You are in page number 1"
Else
Response.Write "You are in page number " & intPageNumber & ""
End If
%>


IsNull

IsNull tr? gi� tr? Boolean khi m?t bi?u th?c ch?a d? li?u kh�ng h?p l?. C� ph�p c?a IsNull nh? sau:

IsNull(bi?u th?c)


IsNumeric

IsNumeric tr? gi� tr? Boolean khi m?t bi?u th?c ???c ki?m ??nh l� m?t s?. C� ph�p c?a IsNumeric nh? sau:

IsNumeric(bi?u th?c)

V� d?:

<%
Dim intSongID
intSongID = Request.Querystring("songid")
If IsNumeric(intSongID) = False Then
Response.Write "The song you are looking for is not in our server."
Else
Response.Write "You are listening song number " & intSongID & ""
End If
%>


IsObject

IsObject tr? gi� tr? Boolean khi c�c tham chi?u c?a bi?u th?c l� m?t ??i t??ng t? ??ng OLE h?p l?. C� ph�p c?a IsObject nh? sau:

IsObject(Bi?u th?c)

??i s? c?a bi?u th?c c� th? l� m?t bi?u th?c b?t k?. IsObject tr? gi� tr? True n?u bi?u th?c l� bi?n c?a m?t ki?u ??i t??ng ph? ho?c m?t ??i t??ng do l?p tr�nh vi�n ??nh ngh?a, ng??c l?i n� tr? k?t qu? False.

V�i v� d?:

<%
dim x
set x=me
document.write(IsObject(x))
%>


K?t qu?:
True


<%
dim x
x="me"
document.write(IsObject(x))
%>

Output:

False


VarType

VarType tr? gi� tr? ch? ??nh ki?u ph? c?a m?t bi?n. C� ph�p nh? sau:

VarType(T�n bi?n)

??i s? T�n bi?n c� th? l� m?t bi?n b?t k?.








This entry was posted on 02:03 and is filed under , .Follow any comments here with the RSS 2.0 . You can leave a response so that we can know your suggestion.
0 Responses to "C�c H�m Ki?m Tra Bi?n"

Đăng nhận xét