Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2005, 07:29 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default This would be easy in C: Array Q

AutoCAD has VBA behind it, and many of its own functions.
One of those is the function to add a block to a drawing.
Following is a routine that adds the named block, "B,"
at the location x=20, y=15, z=0,
x-scaling=1, y-scaling=1, z-scaling=1,
rotation=0:
Code:
Public Sub A()

    Dim x As Object

    With ThisDrawing.PaperSpace
        Set x = .InsertBlock( _
                Array(20, 15, 0), _
                "B", 1, 1, 1, 0) ' This fails. Invalid Procedure call.

        Dim r(0 To 2) As Double
        r(0) = 20
        r(1) = 15
        Set x = .InsertBlock( _
                r, _
                "B", 1, 1, 1, 0) ' This flies.
    End With

End Sub
So apparently, a Variant(array) will not do, but a true array of Doubles will.

So I tried to write the following:
Code:
Public Function CPoint( X_Dim As Double,    _
                        Y_Dim As Double,    _
               Optional Z_Dim As Double = 0 _
                       ) As Double()

    ReDim CPoint(0 To 2)

          CPoint(0) = X_Dim ' See following text.
          CPoint(1) = Y_Dim
          CPoint(2) = Z_Dim

End Function
Of course, the point where the comment says "See following text." tries to see the CPoint(0) as a recursive function call, making the assignation an invalid operation:

   "Function call on left-side of assignment must return Variant or Object."


But I want to be able to use the format:
Code:
Set x = .InsertBlock( _
        CPoint(20, 15), _
        "B", 1, 1, 1, 0)
Thoughts?
 
Old January 6th, 2005, 03:00 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I didn't think you could assign proper arrays, but only Variant(array)s.

But the following is working; go figure!:
Code:
Public Function CPoint( X_Dim As Double,    _
                        Y_Dim As Double,    _
               Optional Z_Dim As Double = 0 _
                      ) As Double()

    Dim a(0 To 2) As Double
        a(0) = X_Dim 
        a(1) = Y_Dim
        a(2) = Z_Dim

    CPoint = a

End Function





Similar Threads
Thread Thread Starter Forum Replies Last Post
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
Easy One ru1 Access 2 September 15th, 2006 10:36 PM
Probably easy but... AMP - Max Current BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 December 20th, 2004 02:55 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
This should be easy benibell Javascript 1 June 22nd, 2004 05:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.