• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2923
  • Last Modified:

Variable uses an Automation type not supported in Visual Basic

I write function - ClearHTMLTags using RegExp object

I use it in some DLL.
When i use this function it make error like:
"Variable uses an Automation type not supported in Visual Basic"

what is the problem?
0
kaspiton
Asked:
kaspiton
  • 12
  • 7
  • 4
  • +2
1 Solution
 
kaspitonAuthor Commented:
This is a function:

Public Function ClearHTMLTags(strHTML As String, intWorkFlow As Integer) As String
    On Error GoTo ClearHTMLTagsErr
   
    'Variables used in the function
 
    Dim regEx As RegExp
    Dim strTagLess As String

    '---------------------------------------
    strTagLess = strHTML
    'Move the string into a private variable
    'within the function
    '---------------------------------------
 
    'regEx initialization
 
    '---------------------------------------
    Set regEx = New RegExp
    'Creates a regexp object
    regEx.IgnoreCase = True
    'Don't give frat about case sensitivity
    regEx.Global = True
    'Global applicability
    '---------------------------------------

    'Phase I
    ' "bye bye html tags"
       
    If intWorkFlow <> 1 Then
 
      '---------------------------------------
      regEx.Pattern = "<[^>]*>"
      'this pattern mathces any html tag
      strTagLess = regEx.Replace(strTagLess, "")
      'all html tags are stripped
      '---------------------------------------
 
    End If
 
    'Phase II
    ' "bye bye rouge leftovers"
    ' "or, I want to render the source"
    ' "as html."
 
    '---------------------------------------
    'We *might* still have rouge < and >
    'let's be positive that those that remain
    'are changed into html characters
    '---------------------------------------
 
    If intWorkFlow > 0 And intWorkFlow < 3 Then
 
        regEx.Pattern = "[<]"
        'matches a single <
        strTagLess = regEx.Replace(strTagLess, "&lt;")
 
        regEx.Pattern = "[>]"
        'matches a single >
        strTagLess = regEx.Replace(strTagLess, "&gt;")
        '---------------------------------------
     
    End If

    '---------------------------------------
    ClearHTMLTags = strTagLess
    'The results are passed back
    '---------------------------------------
    'Clean up
    '---------------------------------------
    Set regEx = Nothing
    'Destroys the regExp object
    '---------------------------------------

  End Function
0
 
nigelroweCommented:
Are you sure that a reference is made to RegExp in the dll project? Check the dll project.
0
 
kaspitonAuthor Commented:
What you mean?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
nigelroweCommented:
Open the VB project, click on Project, click on References. You will see a dialog box showing the references that are held by the project. Check that..

Microsoft VBScript Regular Expressions is in the list and checked. If not, find it in the list and check it. Click on accept and recompile the dll.
0
 
kaspitonAuthor Commented:
Ok.
Yes it`s in list.
Different i don`t can compilate the DLL!
0
 
nigelroweCommented:
What does it say?
0
 
kaspitonAuthor Commented:
I have DLL with this function.
I can`t create dll whithout VBScript Regular Expressions,
if i use there RegExp.
0
 
kaspitonAuthor Commented:
I have DLL with this function.
I can`t create dll whithout VBScript Regular Expressions,
if i use there RegExp.
0
 
nigelroweCommented:
It is in the list of references and its checkbox is checked?

What is the error message displayed when you try to compile?
0
 
kaspitonAuthor Commented:
I have DLL with this function.
I can`t create dll whithout VBScript Regular Expressions,
if i use there RegExp.
0
 
kaspitonAuthor Commented:
I have DLL with this function.
I can`t create dll whithout VBScript Regular Expressions,
if i use there RegExp.
0
 
kaspitonAuthor Commented:
there are no error message displayed when i compile.
I already compiled DLL.

the error :
""Variable uses an Automation type not supported in Visual Basic"
when i use this function from asp page.
0
 
amebaCommented:
>Public Function ClearHTMLTags(strHTML As String, intWorkFlow As Integer) As String

For ASP, you must change arguments (parameters) to Variant:

Public Function ClearHTMLTags(strHTML As Variant, intWorkFlow As Variant) As String

Since ByRef checks type of variable (e.g. if parameter is string, you must pass a string), you must use the same variable type.  In ASP you cannot define variable "As String" or "As Integer", i.e. in ASP all variables are Variant.  So you should change argument types to Variant.
0
 
kaspitonAuthor Commented:
there are no error message displayed when i compile.
I already compiled DLL.

the error :
""Variable uses an Automation type not supported in Visual Basic"
when i use this function from asp page.
0
 
amebaCommented:
kaspiton,
to refresh the page, do not use Refresh button, use "Reload question" link (top-right of this page)
0
 
kaspitonAuthor Commented:
yes.
ok.
0
 
amebaCommented:
Or, better, do not use ByRef - I see you do not modify your parameters inside your function, and you don't need [in]+[out] functionality. Use ByVal (passes parrameter one-way, [in])

Public Function ClearHTMLTags(BYVAL strHTML As String, BYVAL intWorkFlow As Integer) As String
0
 
amebaCommented:
The third solution (if you cannot recompile DLL) is to pass EXPRESSION instead of VARIABLE.

in ASP:

Dim x
result = ClearHTMLTags(x, 1)   ' pass x VARIABLE - this gives error

' these samples work, since, when passing expression, you are really passing ByVal
result = ClearHTMLTags(CStr(x), 1) ' pass expression
result = ClearHTMLTags((x), 1) ' pass expression
result = ClearHTMLTags(x & "", 1) ' pass expression
0
 
amebaCommented:
>third solution
Well, it's not real solution (that function is not asp-friendly), it's a trick.
0
 
Murtuza111000Commented:
Check for the parameters for all the procedures in the RegExp.dll, one or more than one procedure is accepting parameters that is of UDT type, surprisingly this happens only on WinNT4 or lower server and workstation only.

Convert the parameter from UDT to a class object, if you can recompile RegExp.Dll
0
 
kaspitonAuthor Commented:
to ameba:
in this solutions:

Public Function ClearHTMLTags(BYVAL strHTML As String, BYVAL intWorkFlow As Integer) As String

or

Dim x
result = ClearHTMLTags(x, 1)   ' pass x VARIABLE - this gives error

' these samples work, since, when passing expression, you are really passing ByVal
result = ClearHTMLTags(CStr(x), 1) ' pass expression
result = ClearHTMLTags((x), 1) ' pass expression
result = ClearHTMLTags(x & "", 1) ' pass expression

it still make error in ASP:

    Exception occurred.

    /iisHelp/common/500-100.asp, line 192

i think in function ClearHTMLTags(x, 1)
the proble is x variable.
the error occured in the statment
strTagLess = regEx.Replace(strTagLess, "")

0
 
amebaCommented:
Hi, I tested all in VB and it worked.  Sorry, I cannot test ASP + VB combination, but I don't see how can this line / strTagLess = regEx.Replace(strTagLess, "") / produce error (I tried passing Null, but it works).

Maybe you can modify both ASP and VB function for richer error info... e.g. in VB add parameter "LastGoodLine As Variant" and fill it after each executed line, and in ASP, use:

  On Error Resume Next
  Dim GoodLine
  result = ClearHTMLTags(x & "", 1, GoodLine)   ' extra parameter
  If Err <> 0 Then
      Response.Write Err.Number & ": " & Err.Description & "! Line: " & GoodLine
  End If
0
 
DanRollinsCommented:
Hi kaspiton,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept ameba's comment(s) as an answer.

kaspiton, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
kaspitonAuthor Commented:
I don`t get right answer!
0
 
DanRollinsCommented:
kaspiton,
It is unlikely that you will get an answer on this year-old question.   When you do not respond to a question on over one year, we assume that you have abandoned it and we need to finalize it.  

If you would like to have this question deleted, then please post a comment that says that.  Then, if no expert objects in 7 days, an Experts-Exchange Moderator will delete the question for you.

What do you want to do?
0
 
amebaCommented:
Hi,
I'm not real ASP expert and if my comments didn't solve "Variable uses an Automation type not supported" error, please do remove points I got here (DELETE question or whatever you are doing with such questions).
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 12
  • 7
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now