Dim v1
v1=5.43
Response.Write "Type of " & TypeName(v1)
Response.Write "<br>"
Response.Write CInt(v1) ' Output will be 5Response.Write CDbl(v1) ' Output will be 5.43
CDate() converts an expression to a Date value. String-to-date conversion depends on the server locale, so avoid ambiguous numeric date strings when possible.
Dim eventDate
eventDate = CDate("September 22, 2026")
Response.Write eventDate
When you already have numeric year, month, and day components, DateSerial() is usually clearer.
Dim raw
raw = "42"
If IsNumeric(raw) Then
Response.Write CInt(raw) + 1
Else
Response.Write "Please enter a number"
End IfOutput:
43This avoids calling CInt() on arbitrary text. Real form submissions also need error handling and range checks.
CDate() can depend on regional date settings, and CInt() rounds rather than truncating. Check IsNumeric() or IsDate() and handle conversion errors before processing user input.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.