[thelist] VBScript/ASP string concatenation problem
Chris at globet.com
Chris at globet.com
Wed Jul 27 12:32:59 CDT 2005
Ron
> I'm using the fileSystemObject to check to see if a PDF file
> exists. The path to the file is dynamic, based on a number of
> fields in the db query.
> I'm trying to assign that dynamic path to a variable but am
> having problems contatenating.
>
> fsPath= "documents/aldermen/agendas/" &
> Year(DetailsRecordSet.Fields.Item("eventDate").Value) & "/" &
> Details.RecordSet.Fields.Item("committeeCode").Value &
> fncFmtDate((DetailsRecordSet.Fields.Item("eventDate").Value),
> "%b%d%Y") & "agd.pdf"
>
> The above returns an Object required: " error.
>
> I understand why its generating the error but not how to
> properly contatenate the strings and values together. Any
> help or pointers to documentation or how-tos on the web would
> be greatly appreciated.
The ampersand is a concatenation operator on strings in VBScript. Thus,
you require each of the component parts of the following representation
to be strings.
fsPath = [path]/[year]/[committeeCode][eventDate][suffix]
In this case, you could try something along the following lines:
Dim strPath
Dim strYear
Dim strCommitteeCode
Dim strEventDate
Dim strSuffix
strYear = CStr(Year(DetailsRecordSet.Fields.Item("eventDate").Value))
strCommitteeCode =
CStr(Details.RecordSet.Fields.Item("committeeCode").Value)
strEventDate =
CStr(fncFmtDate(DetailsRecordSet.Fields.Item("eventDate").Value))
strSuffix = "agd.pdf"
fsPath = strPath & strYear & strCommitteeCode & strEventDate & strSuffix
This should make it easier to work on, and will also give you a more
accurate idea of exactly where the error is being generated.
Regards
Chris Marsh
More information about the thelist
mailing list