1

I have the following code

<% 
txt = ""+(rs_email.Fields.Item("g_email_body").Value)+""
Set objReg = CreateObject("vbscript.regexp")
objReg.Pattern = "[activate]"
activate = (objReg.Replace(txt,"http://www.gamtool.com/activate.asp?id="+(Recordset1.Fields.Item("g_userbase_id").Value)+""))
%>

When I run the code I get an error on the last line

activate = (objReg.Replace(txt,"http://www.gamtool.com/activate.asp?id="+(Recordset1.Fields.Item("g_userbase_id").Value)+""))
    %>

any ideas why I am getting the error?

I have updated the code above to the following:

<%
  Set regEx = New RegExp
  regEx.Global = true
  regEx.IgnoreCase = True
  regEx.Pattern = "\[activate\]"
  strText = ""+(rs_email.Fields.Item("g_email_body").Value)+""
  activate = regEx.Replace(strText, ""+(Recordset1.Fields.Item("g_userbase_id").Value)+"")
%>

If I change the ""+(Recordset1.Fields.Item("g_userbase_id").Value)+"") to any value but insert the value static then it works.

Thanks

5
  • What is the actual text from the error? Commented Mar 25, 2011 at 11:29
  • Microsoft VBScript runtime error '800a000d' Type mismatch /email.asp, line 49 - This is the line as above Commented Mar 25, 2011 at 11:38
  • Try splitting the problematic line into multiple lines: 1) value = Recordset1.Fields.Item("g_userbase_id").Value 2) url = "http://www.gamtool.com/activate.asp?id=" + (value) + "" 3) activate = (objReg.Replace(txt, url)) On which of these lines does the error occur? Commented Mar 25, 2011 at 11:58
  • Hi Helen the problem seem to be the dynamic value from the db Commented Mar 25, 2011 at 13:57
  • 3
    What is the type of the g_userbase_id field then? It looks like you're trying to convert it into a string by concatenating empty strings. First you should use an explicit conversion function like CStr() to make it the type you need, and/or you should be using an ampersand for concatenation instead of a plus sign. Commented Mar 25, 2011 at 15:43

1 Answer 1

1

@Gerald Ferreira: Instead of using +, use & to concatenate. You're getting the type mismatch error because VB Script thinks you're trying to add which, of course, isn't the same as concatenating.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.