Solved

Variable uses an Automation type not supported in Visual Basic

Posted on 2001-07-18
26
2,877 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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
 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HOW D I CLEAR PICTURES IN IMAGE CONTROL AND COMMENTS IN CELLS WHEN WORKBOOK IS OPENED 18 103
VBA Shell can't Find Word document 11 112
vbModal 12 57
Export Data to Different .csv Files 26 114
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
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…

856 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