Solved

Variable uses an Automation type not supported in Visual Basic

Posted on 2001-07-18
26
2,858 Views
Last Modified: 2013-11-25
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
Comment
Question by:kaspiton
  • 12
  • 7
  • 4
  • +2
26 Comments
 

Author Comment

by:kaspiton
ID: 6292679
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
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6292723
Are you sure that a reference is made to RegExp in the dll project? Check the dll project.
0
 

Author Comment

by:kaspiton
ID: 6292740
What you mean?
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6292891
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
 

Author Comment

by:kaspiton
ID: 6292938
Ok.
Yes it`s in list.
Different i don`t can compilate the DLL!
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6292975
What does it say?
0
 

Author Comment

by:kaspiton
ID: 6292987
I have DLL with this function.
I can`t create dll whithout VBScript Regular Expressions,
if i use there RegExp.
0
 

Author Comment

by:kaspiton
ID: 6293033
I have DLL with this function.
I can`t create dll whithout VBScript Regular Expressions,
if i use there RegExp.
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6293035
It is in the list of references and its checkbox is checked?

What is the error message displayed when you try to compile?
0
 

Author Comment

by:kaspiton
ID: 6293048
I have DLL with this function.
I can`t create dll whithout VBScript Regular Expressions,
if i use there RegExp.
0
 

Author Comment

by:kaspiton
ID: 6293072
I have DLL with this function.
I can`t create dll whithout VBScript Regular Expressions,
if i use there RegExp.
0
 

Author Comment

by:kaspiton
ID: 6293092
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
 
LVL 15

Expert Comment

by:ameba
ID: 6293142
>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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:kaspiton
ID: 6293150
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
 
LVL 15

Expert Comment

by:ameba
ID: 6293156
kaspiton,
to refresh the page, do not use Refresh button, use "Reload question" link (top-right of this page)
0
 

Author Comment

by:kaspiton
ID: 6293197
yes.
ok.
0
 
LVL 15

Expert Comment

by:ameba
ID: 6293200
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
 
LVL 15

Expert Comment

by:ameba
ID: 6293250
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
 
LVL 15

Expert Comment

by:ameba
ID: 6293268
>third solution
Well, it's not real solution (that function is not asp-friendly), it's a trick.
0
 

Expert Comment

by:Murtuza111000
ID: 6293292
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
 

Author Comment

by:kaspiton
ID: 6297281
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
 
LVL 15

Accepted Solution

by:
ameba earned 50 total points
ID: 6297567
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 7156156
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
 

Author Comment

by:kaspiton
ID: 7156290
I don`t get right answer!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7156436
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
 
LVL 15

Expert Comment

by:ameba
ID: 7156710
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now