|
-
Jun 27th, 2001, 08:46 AM
#1
Thread Starter
Addicted Member
Type mismatch. where am I going wrong???
I keep getting this error.
06/27/01 08:35:05 Run time error at line 69. Source: Microsoft VBScript runtime error Error: 800a000d. Description: Type mismatch
here is the code piece that keeps failing.
rpc = Replace(objmessage.Text, chr(13), " ",,,vbBinaryCompare)
rpc = Replace(x(15), chr(10), " ",,,vbBinaryCompare)
Anyone know why.
I have included the whole code below.
Code:
<SCRIPT RunAt=Server Language=VBScript>
'------------------------------------------------------------------------------
'FILE DESCRIPTION: Exchange Server Event Script
'------------------------------------------------------------------------------
Option Explicit
'------------------------------------------------------------------------------
' Global Variables
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
' Event Handlers
'------------------------------------------------------------------------------
' DESCRIPTION: This event is fired when a new message is added to the folder
Public Sub Folder_OnMessageCreated
Dim objMessage
Dim CDOSession
Set CDOSession = EventDetails.Session
Set objMessage = CDOSession.GetMessage(EventDetails.MessageID,Null)
Dim x(20), z
Dim y
dim rpc
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("\\howbp05\runtimenews$\index.html", 1, True)
Dim fso2, f2
Set fso = CreateObject("Scripting.FileSystemObject")
Set f2 = fso.OpenTextFile("\\howbp05\runtimenews$\live.html", 2, True)
Do Until y > 0
x(0) = f.readline
f2.writeline x(0)
y = InStr(1, x(0), "RunTimeTable", vbTextCompare)
Loop
x(1) = f.readline
f2.writeline x(1)
x(2) = f.readline
f2.writeline x(2)
x(3) = f.readline
z = Left(x(3), InStrRev(x(3), Chr(34) & ">", -1, vbTextCompare) + 1)
f2.writeline z & objmessage.sender & "</FONT></P>"
x(4) = f.readline
f2.writeline x(4)
x(5) = f.readline
f2.writeline x(5)
x(6) = f.readline
z = Left(x(6), InStrRev(x(6), Chr(34) & ">", -1, vbTextCompare) + 1)
f2.writeline z & objmessage.TimeSent & "</FONT></P>"
x(7) = f.readline
f2.writeline x(7)
x(8) = f.readline
f2.writeline x(8)
x(9) = f.readline
z = Left(x(9), InStrRev(x(9), Chr(34) & ">", -1, vbTextCompare) + 1)
f2.writeline z & objmessage.subject & "</FONT></P>"
x(10) = f.readline
f2.writeline x(10)
x(11) = f.readline
f2.writeline x(11)
x(12) = f.readline
rpc = Replace(cstr(objmessage.Text), chr(13), " ",,,vbBinaryCompare)
rpc = Replace(x(15), chr(10), " ",,,vbBinaryCompare)
z = Left(x(12), InStrRev(x(12), Chr(34) & ">", -1, vbTextCompare) + 1)
f2.writeline z & x(15) & "</FONT></P>"
x(13) = f.readline
f2.writeline x(13)
x(14) = f.readline
f2.writeline x(14)
'end of table line
'append on the orig line.
f2.writeline x(1)
f2.writeline x(2)
f2.writeline x(3)
f2.writeline x(4)
f2.writeline x(5)
f2.writeline x(6)
f2.writeline x(7)
f2.writeline x(8)
f2.writeline x(9)
f2.writeline x(10)
f2.writeline x(11)
f2.writeline x(12)
f2.writeline x(13)
f2.writeline x(14)
Do Until f.AtEndOfStream
x(0) = f.readline
f2.writeline x(0)
Loop
objmessage.delete
f.Close
f2.Close
' Const ForReading = 1, ForWriting = 2, ForAppending = 8
' Dim fso, f
' Set fso = CreateObject("Scripting.FileSystemObject")
' Set f = fso.OpenTextFile("\\howbp05\runtimenews$\live.txt", ForAppending, True)
'on error resume next
' f.WriteLine "BOSender"
' f.WriteLine objmessage.sender
' f.WriteLine objmessage.subject
' f.WriteLine objmessage.TimeSent
' f.WriteLine "BOMess"
' f.WriteLine objmessage.text
' f.WriteLine "EOMess"
' f.Close
' objmessage.delete
End Sub
' DESCRIPTION: This event is fired when a message in the folder is changed
Public Sub Message_OnChange
End Sub
' DESCRIPTION: This event is fired when a message is deleted from the folder
Public Sub Folder_OnMessageDeleted
End Sub
' DESCRIPTION: This event is fired when the timer on the folder expires
Public Sub Folder_OnTimer
End Sub
</SCRIPT>
-
Jun 27th, 2001, 08:58 AM
#2
Frenzied Member
Okay, I need to look some more, but try using 0 instead of vbBinaryCompare (or publicly declare vbBinaryCompare and set it to 0).
I've never used char() in VBScript, so I'll have to check to make sure you can.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jun 27th, 2001, 09:24 AM
#3
Thread Starter
Addicted Member
I've seen other code that leads me to believe that chr(13) can be used in vbs. I think the problem is in the objmessage.text
I don't know how to get around that.
I also tryed using 0 instead of vbBinaryCompare, nada
-
Jun 27th, 2001, 09:58 AM
#4
Hyperactive Member
In vbscript, if you use one optional parameter, then you must use them all. So your code:
rpc = Replace(objmessage.Text, chr(13), " ",,,vbBinaryCompare)
violates this rule, because you use the compare method but do not have values set for [start,[count.
To get your code to work, set it up like the following:
VB Code:
'=========================
'to test, just create a vbscript and
'run on the desktop
'Replace Method Syntax:
'Replace(expression, find, replacewith[, start[, count[, compare]]])
'=========================
Dim rpc
Dim test_test
test_test="this is a test test" & vbcrlf & "new line is here"
msgbox test_test
rpc = Replace(test_test, chr(13), " ",1,-1,vbBinaryCompare)
rpc = Replace(rpc, chr(10), " ")
msgbox rpc
As you can see, in my first replace statement, I made start=1 (tells the script to begin at the start of the string) and count to -1, which tells the script to replace all occurences. Once these two properties are set, then I can use the vbBinaryCompare. In the second replace statement, I left those optional parameters out, and it worked exactly as the function above.
Quick note here, when the optional parameters are not defined, vbscript will automatically assume that start is =1, count is = -1 and compare is = vbBinaryCompare.
Hope this helps.
-
Jun 27th, 2001, 10:05 AM
#5
Thread Starter
Addicted Member
Excellent
I did not know that. That worked, thanks alot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|