Want to try to do a simple read RSS news page

Source: Internet
Author: User
Tags date definition empty end eval integer string variable
rss| page |rss Many times when we use the Asp+ database to program a website, when a record is read and other variables are calculated, a null value may result in the program returning an error, if each read statement is followed by a judgment statement And the program seems to be procrastinating, so I think it's a good idea to write a dedicated function to automatically or automatically recognize the records you read.

Based on the data type definition of VBScript, combined with the VarType function, the following automatic processing function initdatatype is constructed,
Enter two parameters to process the data itself (thedate) and the data type (Thereturntype, integer) that is ready to be exported: Thereturntype The data type that is forced to return, as is the meaning of the VarType return value definition, ' thereturntype If omitted: Returns the same data type as thedate.

More common null returns, returns an empty string for a string, returns a value of 0 for various values, returns False (false) for a logical value, and for a date

Returns the earliest date

Function Program:
Function Initdatatype (Thedate,thereturntype)
' Returns or forces a value indicating the variable quantum type. The Thedate parameter can be any variable.
' Thereturntype (integer type): Force returned data type, same as VarType return value definition
' Thereturntype If omitted: Returns the same data type as thedate.

' The function referenced below VarType (varname) Returns the value indicating the variable quantum type. , the varname parameter can be any variable.
The meaning of the ' VarType function return value is as follows:
' Vbempty 0 Empty (uninitialized)
' Vbnull 1 Null (no valid data)
' Vbinteger 2 integers
' Vblong 3 long integers
' Vbsingle 4 single-precision floating-point numbers
' Vbdouble 5 double-precision floating-point number
' Vbcurrency 6 currency
' Vbdate 7th period
' Vbstring 8 string
' Vbobject 9 Automation objects
' Vberror 10 Error
' Vbboolean a Boolean
' Vbvariant variant (used only with variable arrays)
' vbDataObject 13 data Access Objects
' VB???? 14 Decimal
' Vbbyte 17 bytes
' VBArray 8192 array

On Error Resume Next
' Err.Clear
Dim n_datatype,vo_redata,vo_renewdata,c_typename

N_datatype = VarType (thedate)
' C_typename = TypeName (thedate)
If N_datatype<2 Then
If IsNumeric (Thereturntype) Then
Select Case Thereturntype
Case 1
Vo_renewdata=null
Case 2
Vo_renewdata=0
Case 3
Vo_renewdata=0
Case 4
Vo_renewdata=0
Case 5
Vo_renewdata=0
Case 6
Vo_renewdata=0
Case 7
Vo_renewdata=0
Case 8
Vo_renewdata= ""
Case 11
Vo_renewdata=def_false
Case 14
Vo_renewdata=0
Case 17
VO_RENEWDATA=CHR (0)
Case Else
Vo_renewdata=thedate
End Select
Else
Vo_renewdata=thedate
End If
Else
If IsNumeric (Thereturntype) Then
Select Case Thereturntype
Case 0
Vo_renewdata=empty
Case 1
Vo_renewdata=null
Case 2
If IsNumeric (thedate) Then
Vo_renewdata=cint (Thedate)
Else
Vo_renewdata=eval ("0+" & Thedate & "")
If not IsNumeric (vo_renewdata) then vo_renewdata=0
End If
Case 3
If IsNumeric (thedate) Then
VO_RENEWDATA=CLNG (Thedate)
Else
Vo_renewdata=eval ("0+" & Thedate & "")
If not IsNumeric (vo_renewdata) then vo_renewdata=0
End If
Case 4
If IsNumeric (thedate) Then
Vo_renewdata=csng (Thedate)
Else
Vo_renewdata=eval ("0+" & Thedate & "")
If not IsNumeric (vo_renewdata) then vo_renewdata=0
End If
Case 5
If IsNumeric (thedate) Then
Vo_renewdata=cdbl (Thedate)
Else
Vo_renewdata=eval ("0+" & Thedate & "")
If not IsNumeric (vo_renewdata) then vo_renewdata=0
End If
Case 6
&nb



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.