VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

routine not accepting string

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
221 Views, 7 Replies

routine not accepting string

Hello all,

The problem I am having is with an Autocad Map routine, but I beleive you
may have encountered this elsewhere so I am posting here.

I am using a built in function that uses a boolean to determine if the
routine is successful. The function accepts parameters like this:

Function SetDataCond(kDataType As Long, kOp As Long, bstrTable As
String, bstrField As String, vValue) As Boolean

When debugging, I call the function using literal strings:

IsSuccess = objQLeaf.SetDataCond(kDataIRD, kCondEq, "SECTIONS",
"SECTION", "1s1e10")

and it works great. However, when I attempt to make this more useful for my
eventual application, and try to replace the vValue parameter "1s1e10" with
a variable declared and containing a string like this:

IsSuccess = objQLeaf.SetDataCond(kDataIRD, kCondEq, "SECTIONS",
"SECTION", strSection)

the code errors on this statement and throws an "invalid procedural call or
arguement". The problem seems simple enough, but I have no idea how to
resolve it.

Any help would be greatly appreciated,

Mike
7 REPLIES 7
Message 2 of 8
Tommy_Kinard
in reply to: Anonymous

The function element vValue is not defined. It is a compile time declaration, which means you either need to define vValue as a string or not define the variable you pass as a string, you may be able to define it as a variant and get away with it.
Message 3 of 8
Anonymous
in reply to: Anonymous

Thank you for the response. The function is a built in one, so I am not able
devife the vValue element. I did define all of the variables I am using to
store and pass information to Variant, but the routine still errors at the
same point. I really think we are on the right path, and appreciate the
assistance in finding the solution.

He is my code:

Public Sub SectionQuery(vList As Variant)
'The next two items are public variables
Set objAMap =
ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application")
Set objProjects = objAMap.Projects

Dim objAcadMapAliases As Object
Dim objAcadMapAlias As Object

Set objAD = objProjects(0).DrawingSet.Add("F:\\AUTO\TAXLOTS.dwg")
Set qryMap = objProjects(0).CurrQuery
qryMap.Clear
qryMap.Mode = kQueryDraw
vSection = vList
Set objQBranch = qryMap.QueryBranch 'get ahold of the main branch

Set objQLeaf = objQBranch.Add(kDataCondition, kOperatorAnd)
IsSuccess = objQLeaf.SetDataCond(kDataIRD, kCondEq, "SECTIONS",
"SECTION", vList)

On this final line, the error is "Run time error '5', Invalid procedure call
or argument". Not sure if this is significant, but at the time of the error,
vSection is listed with Type "Variant/String".

Thanks again for the assistance.

wrote in message news:5330923@discussion.autodesk.com...
The function element vValue is not defined. It is a compile time
declaration, which means you either need to define vValue as a string or not
define the variable you pass as a string, you may be able to define it as a
variant and get away with it.
Message 4 of 8
Tommy_Kinard
in reply to: Anonymous

Public Sub SectionQuery(vList) '<- make this change
The above changes the variant to a compile time declaration. This may work, it may not, just worth a try.

("F:\\AUTO\TAXLOTS.dwg") This doesn't look right.
maybe
("F:\AUTO\TAXLOTS.dwg")
or
("F:\\AUTO\\TAXLOTS.dwg")
Message 5 of 8
Anonymous
in reply to: Anonymous

I made both of the suggested changes. Unfortunately, I get the same result.
Thanks for sticking with me. Any other ideas?

Mike
wrote in message news:5332895@discussion.autodesk.com...
Public Sub SectionQuery(vList) '<- make this change
The above changes the variant to a compile time declaration. This may work,
it may not, just worth a try.

("F:\\AUTO\TAXLOTS.dwg") This doesn't look right.
maybe
("F:\AUTO\TAXLOTS.dwg")
or
("F:\\AUTO\\TAXLOTS.dwg")
Message 6 of 8
Tommy_Kinard
in reply to: Anonymous

No not really, but I have a space cadet guess LOL

IsSuccess = objQLeaf.SetDataCond(kDataIRD, kCondEq, "SECTIONS",
"SECTION", chr(34) & vList & chr(34))

I searched the net and found 4 posts on this, 2 were from you all had problems without the " when it was a literal it works, so since I don't have Map to test with, I am not doing anything but guessing.

If that works I'll dance a jig, but since it's nothing but a guess I don't think I can help Sorry.
Message 7 of 8
Anonymous
in reply to: Anonymous

Dance a jig! I no longer receive an error on that line. I'll have to put
this one in my pocket for future reference. I would not have arrived at a
solution like this. Thanks for your help.

Mike
wrote in message news:5333174@discussion.autodesk.com...
No not really, but I have a space cadet guess LOL

IsSuccess = objQLeaf.SetDataCond(kDataIRD, kCondEq, "SECTIONS",
"SECTION", chr(34) & vList & chr(34))

I searched the net and found 4 posts on this, 2 were from you all had
problems without the " when it was a literal it works, so since I don't have
Map to test with, I am not doing anything but guessing.

If that works I'll dance a jig, but since it's nothing but a guess I don't
think I can help Sorry.
Message 8 of 8
Tommy_Kinard
in reply to: Anonymous

Woo Whoo!
Every once in a while that will work, I just never know when it will and when it won't.

Later

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost