Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Classes in VB 6 - create in code?

Status
Not open for further replies.

KenWK

Programmer
May 25, 2001
76
US
Greetings,

This might be a bit vague but I think its a pretty general question. I'm new to using classes (so please bear with me) and have picked up some VB script code from Adobe for working with XML in InDesign. I'm adapting the VBS to VB 6.

In VB 6 I've created a class module that will represent what Adobe terms an XML Rule. My concern is that I'm going to need a bunch of these rules and the only way I can readily see in VB 6 to create the classes is with class modules. This will create more class module files than I care to try to manage.

I've called the class module AddReturns and it has only this in it:
Code:
Public Property Get name()
    name = "AddReturns"
End Property
Public Property Get xpath()
    xpath = "//*"
End Property
Public Function apply(myXMLElement, myRulesProcessor)
    With myXMLElement
        Rem Add a return character after the end of the XML element
        Rem (this means that the return does not become part of the
        Rem XML element data, but becomes text data associated with the
        Rem parent XML element).
        .InsertTextAsContent vbCr, idXMLElementPosition.idAfterElement
    End With
    Rem Enter true to stop further processing of this element.
    apply = False
End Function

Is there any way to create an equivalent class/object with code like there is in VBS? I'd like to be able to create these classes in one module file that we can pick up as we create more VB projects to deal with the XML.

Many thanks,
Ken
 
No, there is no way to do that.

I'm not entirely sure how you plan to tie VB6 code into this script host anyway. Are you planning to build a DLL full of these classes that can be used from script or something? Did I miss something about an Automation interface the products offers so that a VB6 program might control it externally?

Looking at their documentation a little, it appears they have a warped notion of what classes are for. I can see that they are trying to use them in a way often abused in JavaScript, so I suppose that's where they get their funny ideas.
 
Dang!

When the Adobe programs load they install and register VB components that you can reference in the VB project. We've been creating EXE files from VB6.

I think you're exactly right on the "funny ideas" for classes and Java. The main scripting language seems to be Java, I think it may have been the first one they had up and running. I can't remember in which Adobe APPs, I THINK it was Photoshop, but I've come across things that don't exist in VB but exist in Java. In those few instances I've run the Java code from VB with the DoScript command, which works pretty well.

Thanks a bunch for the info.

Ken
 
Sorry I can't be helpful.

Careful though, there is no Java there only JavaScript. The two are entirely unrelated, different things with a confusing similarity in names and (only apparently) in syntax.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top