Announcement

Collapse
No announcement yet.

PB COM DLL with VB6

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PB COM DLL with VB6

    I wrote a simple PB COM DLL consisting one property, one method and one event. It actually works with VB6 with some differences from other COM objects compiled not in PB:
    1. On a VB Form
    Private WithEvents objSamplePBCOM As New SamplePBCOM.REMAILSEND
    is not accepted. However
    Private WithEvents objSamplePBCOM As SamplePBCOM.REMAILSEND
    is fine and the New keyword is accepted in Form_Load providing the same results. While the results are the same I wish PB would not impose any special handling requirements on users of a DLL written in PB.
    2. It looks like I have to distribute the type library instead of the DLL? Using the DLL was not working for me.
    3. In the events VB displays Param1, Param2 and so on for passed parameters instead of the descriptive name I actually created. I wish if PB would retain the original names otherwise users will have no hint what the parameter is for.
    4. It looks like we have to be very careful handling string values. We have to convert them to unicode before assigning the value to a method or to a parameter in an event or when returning a property value that we modified/created in the PB DLL.
    5. All property names, method names etc. appear in upper case in VB. Is any way of reatining the case I used in the code?

    Peter Redei
    Last edited by Peter Redei; 26 Apr 2009, 06:34 PM.

  • #2
    5. All property names, method names etc. appear in upper case in VB. Is any way of reatining the case I used in the code?
    The same as with standard functions: use ALIAS.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Thanks Jose.
      That works with properties and methods but not with events.
      Example:
      INTERFACE MyClass_Events GUID$("{8D46B53C-6A9B-4A88-BD81-260360BDBC1D}") AS EVENT
      INHERIT IAUTOMATION

      METHOD ProvideComputerName (newComputerName AS STRING)

      END INTERFACE

      is accepted and it will display _ PROVIDECOMPUTERNAME.

      The compiler errors out on this

      INTERFACE MyClass_Events GUID$("{8D46B53C-6A9B-4A88-BD81-260360BDBC1D}") AS EVENT
      INHERIT IAUTOMATION

      METHOD ProvideComputerName alias "ProvideComputerName "(newComputerName AS STRING)

      END INTERFACE

      In addition instead of newComputerName the variable will appear as PARAM1.

      Peter Redei

      Comment


      • #4
        I am sorry, but I do not understand your questions. Can you post your code or send it to support?

        Did you look at the VB/PB COM example at \Samples\COM\VB?
        Sincerely,

        Steve Rossell
        PowerBASIC Staff

        Comment


        • #5
          "It looks like we have to be very careful handling string values."

          Actually I can't imagine not being very careful with any and every value, not just strings. One wrong parameeter and your entire program is likely to be unstable.

          Bob Zale

          Comment


          • #6
            Bob and Steve,

            Thank you for your answers. I uploaded the PB and the VB code as well as the DLL I created. I put comments to both the PB and the VB code.


            Peter Redei
            Attached Files

            Comment


            • #7
              We are not VB experts and probably will never be. Can you explain exactly the purpose of this particular AS NEW clause and why you believe this is a PowerBASIC issue? Can you show me the relevant documentation in Visual Basic.

              As for the PARAM1 name, we will look into this issue.

              In the current version of PowerBASIC interface names are always created in upper case. If you feel there is a benefit to some other manner, I suggest you send in a new feature suggestion with detail of why it would be a benefit to change it.
              Sincerely,

              Steve Rossell
              PowerBASIC Staff

              Comment


              • #8
                Thank you Steve for your prompt reply.

                In regard the New keyword with Private statement in Visual Basic 6.0 I copied here the VB Help:

                ------------------------- from VB6 Help -----------------------------
                Private Statement


                Used atmodule level to declare privatevariables and allocate storage space.

                Syntax

                Private [WithEvents] varname[([subscripts])] [As [New] type] [,[WithEvents] varname[([subscripts])] [As [New] type]] . . .

                The Private statement syntax has these parts:

                Part Description
                WithEvents Optional.Keyword that specifies that varname is anobject variable used to respond to events triggered by anActiveX object. WithEvents is valid only inclass modules. You can declare as many individual variables as you like using WithEvents, but you can't createarrays with WithEvents. You can't use New with WithEvents.
                varname Required. Name of the variable; follows standard variable naming conventions.
                subscripts Optional. Dimensions of an array variable; up to 60 multiple dimensions may be declared. The subscriptsargument uses the following syntax:
                [lower To] upper [,[lower To] upper] . . .
                When not explicitly stated in lower, the lower bound of an array is controlled by the Option Base statement. The lower bound is zero if no Option Base statement is present.
                New Optional. Keyword that enables implicit creation of an object. If you use New when declaring the object variable, a new instance of the object is created on first reference to it, so you don't have to use the Set statement to assign the object reference. The New keyword can't be used to declare variables of any intrinsicdata type, can't be used to declare instances of dependent objects, and can’t be used with WithEvents.
                type Optional. Data type of the variable; may beByte,Boolean,Integer,Long,Currency,Single,Double,Decimal (not currently supported),Date,String (for variable-length strings), String * length (for fixed-length strings),Object,Variant, auser-defined type, or anobject type. Use a separate As type clause for each variable being defined.


                Remarks

                Private variables are available only to the module in which they are declared.

                Use the Private statement to declare the data type of a variable. For example, the following statement declares a variable as an Integer:

                Private NumberOfEmployees As Integer

                You can also use a Private statement to declare the object type of a variable. The following statement declares a variable for a new instance of a worksheet.

                Private X As New Worksheet

                If the New keyword isn't used when declaring an object variable, the variable that refers to the object must be assigned an existing object using the Set statement before it can be used. Until it's assigned an object, the declared object variable has the special value Nothing, which indicates that it doesn't refer to any particular instance of an object.

                If you don't specify a data type or object type, and there is no Deftype statement in the module, the variable is Variant by default.

                You can also use the Private statement with empty parentheses to declare a dynamic array. After declaring a dynamic array, use the ReDim statement within a procedure to define the number of dimensions and elements in the array. If you try to redeclare a dimension for an array variable whose size was explicitly specified in a Private, Public, or Dim statement, an error occurs.

                When variables are initialized, a numeric.

                ------------------------- end of VB6 Help -----------------------------

                Again, PB COM components are working with VB6 regardless this issue. However if we want to sell components developed in PB this difference is a minus in sale.

                Basically the same applies to the 'PowerBASIC interface names are always created in upper case' issue although with less importance since the user has no idea about why interface names are in upper case. I just found it a weird feature. You should not take this issue as a major development requirement.

                Thanks,


                Peter Redei

                Comment


                • #9
                  Originally posted by Steve Rossell View Post
                  We are not VB experts and probably will never be. Can you explain exactly the purpose of this particular AS NEW clause and why you believe this is a PowerBASIC issue? Can you show me the relevant documentation in Visual Basic.

                  As for the PARAM1 name, we will look into this issue.

                  In the current version of PowerBASIC interface names are always created in upper case. If you feel there is a benefit to some other manner, I suggest you send in a new feature suggestion with detail of why it would be a benefit to change it.
                  Steve, if one writes a com interface for an end-user, it is uncommon to have names in uppercase, it appears unprofessional to me.
                  Please allow for an alias or even better, direct passthrough of the name used.

                  I also never understood this for ordinary exported functions as well why they need to in uppercase.
                  It simply brings more work to make a nice an shine name.
                  A possible naming conflict can be solved via an alias anyway.

                  Edwin,
                  hellobasic

                  Comment


                  • #10
                    Hi Peter,

                    Your documentation says:
                    You can't use New with WithEvents.
                    and
                    The New keyword can't be used to declare variables of any intrinsicdata type, can't be used to declare instances of dependent objects, and can’t be used with WithEvents.
                    This would imply that you cannot use the NEW keyword when you also have the WITHEVENTS keyword.

                    If you want Interface names in anything other than uppercase, you should send a request to support for this feature.
                    Sincerely,

                    Steve Rossell
                    PowerBASIC Staff

                    Comment


                    • #11
                      >you should send a request to support for this feature.

                      Ok i have sent this request.
                      Though i want to share a thing that frustrated me for several years.
                      There must be a logic for that but...

                      If you/pb are aware of such requests, why not do this anyway?
                      Is this 'must ask support' some kind of threshold to see if there is enough interest?
                      Really, i have asked my colleague about this, yes we differ and he has an open mind and said that is a possibility some companies do and i left it this way.
                      I am aware that follow up from support is good enough but i never understood the for me trivial follow-up from a message on this board.

                      In the past i had some arguing with PB and that is because i never understood this behaviour.
                      It's therefore i reacted sometimes harsh and never contacted support for things support already could know (by reading this board).

                      Maybe PB can give me some relief on this matter?

                      Just asking..
                      hellobasic

                      Comment


                      • #12
                        Thank you Steve, you are right I overlooked this exception. Without the WithEvents keyword the PB COM object can be created with the Private statement in VB6.


                        Peter Redei

                        Comment


                        • #13
                          It's therefore i reacted sometimes harsh and never contacted support for things support already could know (by reading this board).
                          Somewhere around here it says this board is not an official communications channel. You want to make sure the PBPTB know about something, you have to contact them through an official channel.

                          MCM
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            1)
                            On the website a price for support is mentioned and that creates a some threshold.
                            (In practise they never asked for money the few times i mailed them)

                            2)
                            I sell a product as well, if someone needs a feature i just follow the forum, a hint should do imo.
                            Not providing real support as on this board applies does not mean you just wait until someone mails a request (since contacting may cost money).

                            --

                            The price mentioned and simply not taking a user's hint on a board like this made it me respond the way i did.
                            I may now know better these days and i do make requests through email since a short while but maybe this 'policy' could be enlightened on the website.

                            "If you do have a request, don't ask us on the board but mail it."

                            Confusing.., i would take the hint and not wait for an email.
                            hellobasic

                            Comment


                            • #15
                              Originally posted by Edwin Knoppert View Post
                              1)
                              On the website a price for support is mentioned and that creates a some threshold.
                              The website actually says
                              Free Support

                              PowerBASIC One-on-One Free Technical Support is designed to answer questions about PowerBASIC products. Our assistance includes:
                              • The features of our products
                              • How these features can be used
                              • How to troubleshoot unexpected behavior

                              Other Free Technical Support Resources are available on our web site:
                              • PowerBASIC Peer Support Forums
                              • TechNotes, downloadable updates, tutorials, sample files, sample applications, articles.

                              PowerBASIC One-on-One Free Technical Support is done via e-mail. Please submit one question or issue at a time to [email protected]. This allows our Support Engineers to provide the best possible service. You must include your serial number. We can not accept lists of questions because they slow our response time to all of our customers.
                              Paid Technical Support

                              Custom programming, debugging your program, and issues involving third party products fall outside the bounds of Free Technical Support. Requests for these kinds of services require research and testing beyond the scope of compiler support.
                              Paid Technical Support is $49 per incident. A single support incident is an issue that focuses on one aspect of the product - e.g. use of a specific feature of the product or assistance with a specific problem or error message. A single support incident pays for 30 minutes. Issues that exceed 30 minutes must be classed and billed as multiple incidents.
                              and you can find this at http://www.powerbasic.com/support/support.asp.


                              Originally posted by Edwin Knoppert View Post
                              2)
                              I sell a product as well, if someone needs a feature i just follow the forum, a hint should do imo.
                              Not providing real support as on this board applies does not mean you just wait until someone mails a request (since contacting may cost money).
                              I do not know how busy your forums are, but we cannot simply read every post of every minute of the day. What if we missed a post for a feature request? If you simply send an email to support, there is no way that we could miss it.
                              Sincerely,

                              Steve Rossell
                              PowerBASIC Staff

                              Comment


                              • #16
                                Thank you,

                                Maybe i should get real..

                                hellobasic

                                Comment


                                • #17
                                  VB will have a typelib as Resource!

                                  VB accept PB-Class-Objects with new operator.

                                  Private WithEvents myO As MyPBInterface


                                  Set myO = new MyPBInterface.

                                  Look: http://www.visualbasic.at/forum/show...5051#Post35065 -> In-Process-Server written in PB

                                  (language is in german)
                                  Last edited by Ralph Steinkönig; 29 Apr 2009, 12:41 PM.

                                  Comment

                                  Working...
                                  X