Array Data type difference between PowerBuilder and VB

Dear All:

How to pass an argument type array to a com that written with VB?

Thanks

Nick


0
nick
11/15/2001 2:25:43 AM
sybase.ole-ocx-activex 6324 articles. 0 followers. Follow

6 Replies
523 Views

Similar Articles

[PageSpeed] 14

Nick

A while back I did some experimentation with passing arrays to VB com
objects.  Unfortunately I could not locate my test code and I have forgotten
some of the specifics but here is what I do remember:

I found that I could pass variable length arrays of simple datatypes (long,
integer) by reference without any major problems.  If I called a VB function
that returned an array, I could capture the result in PowerBuilder in a
variable of type Any, but I did encounter some instability when trying to
convert the any variable to a PB array.

One of the most surprising things that I found was that I could use the VB
redim statement to change the size of the array.  This meant that I could
use the VB function to add new items on to the array.  The only thing I had
to be careful of was to use the LowerBound and UpperBound functions to check
the size of the array, or to explicitly set the lower bound of the array in
VB using the syntax  Redim arr( 1 to x ).

If you have both VB and PB on the same PC you can develop and debug both
simultaneously.  If you click on the VB run button, your COM class will be
loaded into memory from the development environment.  If you subsequently
run a PowerBuilder application (either an .exe or from the development
environment), PB will access the development code in memory.  If you set
break points in the VB code, then you can debug the VB code on the fly and
even make code changes (provided the code changes don't force a reset in
VB).  This even works from the PowerBuilder debugger, so you can step
through the PB code, into the VB code, and back again.  I use this technique
a fair bit to build VB wrapper components, particularly to deal with
collections and complex object hierarchies.


Dave Mills
Yaletown Technology Group Inc.



"nick" <nickhsu@eSOON.com> wrote in message
news:L89qQ3XbBHA.358@forums.sybase.com...
> Dear All:
>
> How to pass an argument type array to a com that written with VB?
>
> Thanks
>
> Nick
>
>


0
Dave
11/16/2001 8:11:40 PM
Dear Dave:

    thank you in advance

Nick

"Dave Mills" <davidm@yaletech.com> ���g��l��
news:n6jUNwtbBHA.315@forums.sybase.com...
> Nick
>
> A while back I did some experimentation with passing arrays to VB com
> objects.  Unfortunately I could not locate my test code and I have
forgotten
> some of the specifics but here is what I do remember:
>
> I found that I could pass variable length arrays of simple datatypes
(long,
> integer) by reference without any major problems.  If I called a VB
function
> that returned an array, I could capture the result in PowerBuilder in a
> variable of type Any, but I did encounter some instability when trying to
> convert the any variable to a PB array.
>
> One of the most surprising things that I found was that I could use the VB
> redim statement to change the size of the array.  This meant that I could
> use the VB function to add new items on to the array.  The only thing I
had
> to be careful of was to use the LowerBound and UpperBound functions to
check
> the size of the array, or to explicitly set the lower bound of the array
in
> VB using the syntax  Redim arr( 1 to x ).
>
> If you have both VB and PB on the same PC you can develop and debug both
> simultaneously.  If you click on the VB run button, your COM class will be
> loaded into memory from the development environment.  If you subsequently
> run a PowerBuilder application (either an .exe or from the development
> environment), PB will access the development code in memory.  If you set
> break points in the VB code, then you can debug the VB code on the fly and
> even make code changes (provided the code changes don't force a reset in
> VB).  This even works from the PowerBuilder debugger, so you can step
> through the PB code, into the VB code, and back again.  I use this
technique
> a fair bit to build VB wrapper components, particularly to deal with
> collections and complex object hierarchies.
>
>
> Dave Mills
> Yaletown Technology Group Inc.
>
>
>
> "nick" <nickhsu@eSOON.com> wrote in message
> news:L89qQ3XbBHA.358@forums.sybase.com...
> > Dear All:
> >
> > How to pass an argument type array to a com that written with VB?
> >
> > Thanks
> >
> > Nick
> >
> >
>
>


0
nick
11/19/2001 5:06:08 AM
Nick

I found some test code from a demo application.  (The
demo application returned metadata from diagrams in
Embarcadero ER/Studio.  I used the array resizing code
to return a list of the currently open diagrams.  The VB
application was a wrapper written to manipulate the
ER/Studio collections by implementing FOR EACH
functionality.  I could not use PB because the value of
the Item method in the collection was a numeric object ID,
not an index into the collections.)

1. Method in a VB Object (passing an array of strings):

' Method to return the current contents of an array to PB
' The array is stored as a private module variable, mstrVBArray()

Public Sub ProcessArray(PBArray() As String)

Dim i As Integer

' Resize the passed array to hold the result
' This will clear the contents of the array
' (We could use Redim Preserve to resize without deleting)
' We are explicitly setting the lower bound

ReDim PBArray(1 To UBound(mstrVBArray()))

' Copy the contents of the VB array into the array passed from PB

For i = 1 To UBound(PBArray)
    PBArray(i) = mstrVBArray(i)
Next

End Sub


2. Example of calling the method from PB:

Integer i
String ls_array[]

// Initialise the array - this helps to test the redimensioning
ls_array[1] = "One"

// Call the method in the VB object
// The ref keyword is necessary to pass the array by reference
iobj_myobject.ProcessArray( ref ls_array[] )

// Iterate through the array and see what got passed back
FOR i = LowerBound(ls_array) TO UpperBound(ls_array)
    MessageBox( "Return Value", ls_array[i] )
NEXT


Hope this helps


Dave Mills
Yaletown Technology Group Inc.



0
Dave
11/22/2001 5:02:33 PM
Hi,Dave
    I have a question on passing arrays from VB COM objects back to PB.When
i pass array from VB to PB ,PB can'nt recognize all elements of array .
    for example:
    A VB Com object has a methed GetNameList(NameList as Variant)
    Dim aNameList(2, 2) As String
    aNameList(0, 0) = "0,0"
    aNameList(1, 0) = "1,0"
    aNameList(0, 1) = "0,1"
    aNameList(1, 1) = "1,1"
    NameList = aNameList

    I write PB script as following:
    integer i_ret
    oleobject ole_ComTest
    ole_ComTest = Create OLEObject
    i_ret = ole_ComTest.ConnectToNewObject("ComTest.cComTest")

    any a_ret
    string arr_ret[]
    a_ret = arr_ret                //it seems that i must write this
    ole_ComTest.GetNameList(ref a_ret)

    Now ,i get array in a_ret as a_ret[3]:[1]="0,1" [2]="1,1" [3]=""

    Can help me ?

Thanks in advanced!


Tim




"Dave Mills" <davidm@yaletech.com> wrote in message
news:n6jUNwtbBHA.315@forums.sybase.com...
> Nick
>
> A while back I did some experimentation with passing arrays to VB com
> objects.  Unfortunately I could not locate my test code and I have
forgotten
> some of the specifics but here is what I do remember:
>
> I found that I could pass variable length arrays of simple datatypes
(long,
> integer) by reference without any major problems.  If I called a VB
function
> that returned an array, I could capture the result in PowerBuilder in a
> variable of type Any, but I did encounter some instability when trying to
> convert the any variable to a PB array.
>
> One of the most surprising things that I found was that I could use the VB
> redim statement to change the size of the array.  This meant that I could
> use the VB function to add new items on to the array.  The only thing I
had
> to be careful of was to use the LowerBound and UpperBound functions to
check
> the size of the array, or to explicitly set the lower bound of the array
in
> VB using the syntax  Redim arr( 1 to x ).
>
> If you have both VB and PB on the same PC you can develop and debug both
> simultaneously.  If you click on the VB run button, your COM class will be
> loaded into memory from the development environment.  If you subsequently
> run a PowerBuilder application (either an .exe or from the development
> environment), PB will access the development code in memory.  If you set
> break points in the VB code, then you can debug the VB code on the fly and
> even make code changes (provided the code changes don't force a reset in
> VB).  This even works from the PowerBuilder debugger, so you can step
> through the PB code, into the VB code, and back again.  I use this
technique
> a fair bit to build VB wrapper components, particularly to deal with
> collections and complex object hierarchies.
>
>
> Dave Mills
> Yaletown Technology Group Inc.
>
>
>
> "nick" <nickhsu@eSOON.com> wrote in message
> news:L89qQ3XbBHA.358@forums.sybase.com...
> > Dear All:
> >
> > How to pass an argument type array to a com that written with VB?
> >
> > Thanks
> >
> > Nick
> >
> >
>
>


0
Tim
12/10/2001 7:23:56 AM
Thank you!


"Dave Mills" <davidm@yaletech.com> ���g��l��
news:JjGQki3cBHA.291@forums.sybase.com...
> Nick
>
> I found some test code from a demo application.  (The
> demo application returned metadata from diagrams in
> Embarcadero ER/Studio.  I used the array resizing code
> to return a list of the currently open diagrams.  The VB
> application was a wrapper written to manipulate the
> ER/Studio collections by implementing FOR EACH
> functionality.  I could not use PB because the value of
> the Item method in the collection was a numeric object ID,
> not an index into the collections.)
>
> 1. Method in a VB Object (passing an array of strings):
>
> ' Method to return the current contents of an array to PB
> ' The array is stored as a private module variable, mstrVBArray()
>
> Public Sub ProcessArray(PBArray() As String)
>
> Dim i As Integer
>
> ' Resize the passed array to hold the result
> ' This will clear the contents of the array
> ' (We could use Redim Preserve to resize without deleting)
> ' We are explicitly setting the lower bound
>
> ReDim PBArray(1 To UBound(mstrVBArray()))
>
> ' Copy the contents of the VB array into the array passed from PB
>
> For i = 1 To UBound(PBArray)
>     PBArray(i) = mstrVBArray(i)
> Next
>
> End Sub
>
>
> 2. Example of calling the method from PB:
>
> Integer i
> String ls_array[]
>
> // Initialise the array - this helps to test the redimensioning
> ls_array[1] = "One"
>
> // Call the method in the VB object
> // The ref keyword is necessary to pass the array by reference
> iobj_myobject.ProcessArray( ref ls_array[] )
>
> // Iterate through the array and see what got passed back
> FOR i = LowerBound(ls_array) TO UpperBound(ls_array)
>     MessageBox( "Return Value", ls_array[i] )
> NEXT
>
>
> Hope this helps
>
>
> Dave Mills
> Yaletown Technology Group Inc.
>
>
>


0
nick
12/11/2001 2:48:58 AM
Sorry I missed your question until now.

VB and PB differ in the handling of the zeroth elements in 2D arrays.  I
haven't tried it but you might try explicitly specifying the lower bound of
the array in VB e.g.:

    Dim aNameList(1 to 2, 1 to 2) As String


Dave Mills
Yaletown Technology Group Inc.



0
Dave
2/1/2002 7:07:33 AM
Reply:

Similar Artilces:

PowerBuilder Bugs: Using VB ActiveX control (OCX) in PowerBuilder 6.0
I'm going to write some VB ActiveX control (using Microsoft VB6.0 SP3) to be used in PowerBuiler 6.5, but I found that it's very easy to crash in PowerBuilder, Here is the test case: 1) Create a very simple VB ActiveX control (only one button without any script) in Visual Basic 2) Create a PB project to open a Main Window (w_1) with an ole object of VB ActiveX control 3) Open another Window (w_2) with an ole object of VB ActiveX control (can be same as previous or other control) 4) Click the OLE object in w_2 to make it get focus 5) Close w_2 -> it will crashed If ...

c:\inetpub\wwwroot\WebApplication1\subject_info.aspx.vb(658): Value of type '1-dimensional array of System.Data.DataRow' cannot be converted to 'System.Data.DataRow'.
Hi everyone, I have a "select link" in one of the fields in the DataGrid. I want it retreive informations when i click on that link and display in the text box so i can modify data. The problem is i always have this error when i COMPILE: " Value of type '1-dimensional array of System.Data.DataRow' cannot be converted to 'System.Data.DataRow' ". Here's is my code: ************************************************ Private Sub UpdateDetails(ByVal uSubjectID As String) DaLecturer1 = Session("ds") Dim dt As DataTable = DaLectur...

Can we set control array for OCX like VB in PowerBuilder.
Dear everybody: I am writing a winsock program using Microsoft mswinsock.ocx. One of the requirements that the program can create a winsock.ocx to listen to a new coming socket. In VB, we can create a control array of mswinsock.ocx. But I cannot find a similar feature in PowerBuilder. Can anybody help me on how I can implement a dynamic set of ocx? Thanks Simon I don't believe that control arrays (like the ones in VB) are possible in PB. Craig Gluck Simon Poon wrote in message <38200B87.1C146B0A@hkstar.com>... >Dear everybody: > >I am writing a w...

VB COM (ActiveX dll) OLE from Powerbuilder 10.5
Hello, I have folder/file backup function in my application. To notify the PB window of the progress and status of the backup I use the CopyFileEx (which uses callback) windows api function in visual basic to achieve the file backup The VB project has one main module and one class. The module contains the callback function (the function that will be called by CopyFileEx to notify about the changes and progress of the copy. It also contains the caller function that initiate the CopyFileEx. All that the callback function does is to send a message to a registered PB window ab...

how can i use powerbuilder to develop an activex/ole/ocx? help me please!!!
Please do not cross-post. -- <hopethishelps/> Roy Kiesler [TeamSybase] MySybase -- http://www.sybase.com/mysybase "tadsun" <tadsun@163.com> wrote in message news:jIQ8Mt7BCHA.200@forums.sybase.com... > > > ...

Problem: Different Data type in Oracle 8.0.4 and PowerBuilder 6.5
I've enountered a problem, i.e. in the PowerBuilder script, I need to select one table in Oracle 8, but the field type in Oracle is Number, I can't get the data because the script doesn't support the type Number. For Example create table UserRole ( UserName varchar2(12), PassWord varchar2(12), RoleNum Number(1)); in the script: strUser = sle_1.text; strPass = sle_2.text; integer nRole select RoleNum into :nRole from UserRole where UserName = :strUser and PassWord = :strPass But it doesn't work, would you be kind enough to offer me a solution or...

convert array of structure data type to array of object
Hi I have a problem of send argument to a web service which take an array of structure as argument. anyone know how to convert a array of structure to an array of object which can be recognise by external web service? the error i got is "BC30333: Value of type '1-dimensional array of ASP.cfctestSandBox_aspx.SandboxRules' cannot be converted to '1-dimensional array of System.Object' because 'ASP.cfctestSandBox_aspx.SandboxRules' is not a reference type." Thanks in advance...

different versions of MySql return different data types ?
I've got a production MySql server (version 3.23.56) on a remote computer and a testing server installed locally (version 3.23.58-nt). Both have a copy of the same database (done by dumping one to the other). The problem is that I'm getting type DBNull returned from one (local) and type String returned from the other (remote). This happens when I try to execute reader.getValue(reader.getOrdinal("column_name")) on a record where the cell is empty. The column type in MySql is 'text' and 'Allow Null' is true. The same code is run to achieve this, just with modification o...

Enumerated data types/object type on an activeX control
Hello all. I am experimenting with a 3D rendering activeX. The activeX comes with VB and C++ examples. In the VB example I see a declaration like: Dim TubeFace As vdPolyface From the activeX help file I understand that vdPolyface is an object type. When I try doing a powerbuilder declaration like: vdPolyface L_TubeFace I get a message like 'unknown datatype vdPolyface'. I am not new to powerbuilder but have not done a lot of work with OCX/ActiveX controls. Any help would be appreciated. Thanks I don't believe that PB can 'see' the enums. ...

Need data items w/ same name but different data types
Using PD 9.0.0.580. While trying to map an existing database into a CDM I need to establish data items with different types but identical codes: Let E1 and E2 be entities, and E1 shall get an attribute with name/code CODE and type VA10, while E2 has a CODE with VA20. Do not forget: it's no new model, so renaming data items or changing data types is not an option. PD will not let me a second data item with the same name/code, and if I try to define the second attribute named code, it identifies it with the first one and changes the data type of the code item defined first to t...

How to convert varchar data type into datetime data type without data lose
Hi all, i have stored date as varchar(30) data type and Date format is dd/MM/yyyy now i have to convert it into datatime data type can u help me in query ?  i have 330 records and each recod contain the Date in format of dd/MM/YYYY but due to varchar data type i can not perform calculation on Date so i have to convert into datetime without data lose. please help me in this regard. Best RegardsRameezWaheed  life is name of learning!Mark as an answer if it helps You can check these posts http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2039108&SiteID=17   ...

copying data from one table to a new one with some different data types
Is it possible to easily copy data from one table to another if the data types don't match.   I know you can do a INSERT INTO table1(col1,col2)  SELECT (col2,col7) FROM table2 if the data types match but is there a way to do this if they don't. I'm not trying to copy date times into bit fields or anything.  I just have an old table that I built when I really didn't know what I was doing now I at leastthink I have a better understanding of what data types to use, so I was wanting to move the data in the orignal table to my new one.  Most of the fields in the oldd...

Array of record type with array of record type...
Hi, I wonder how I can resolve these delphi code lines. type TRec1 = packed record R1Name: string; R1Int: Integer; end; TRec2 = packed record R2Name: String; Rec1: array of TRec1; end; ..... const CTERec: array[0..1] of TRec2 = ( (R2Name: 'R2Name1'; Rec1: ( (R1Name: 'R1Name1'; R1Int: 1), (R1Name: 'R1Name2'; R1Int: 2) ), (R2Name: 'R2Name2'; Rec1: ( (R1Name: 'R1Name3'; R1Int: 3) ) ); Delphi compiler stop on the first R1Name with this me...

Difference of array types
Hi. I'm curious if there is any explanation description of the side effects of the following code segments: procedure TForm1.Button1Click(Sender: TObject); var a : Array of integer; b : TIntegerDynArray; i : Integer; begin SetLength(a, 3); SetLength(b, 3); for i := 0 to 3 - 1 do begin a[i] := -1; b[i] := -1; end; ShowMessage(IntTostr(Foo(a))); ShowMessage(IntToStr(Foo(b))); ShowMessage(IntToStr(a[0]) + ' ' + IntToStr(a[1])); ShowMessage(IntToStr(b[0]) + ' ' + IntTo...

Web resources about - Array Data type difference between PowerBuilder and VB - sybase.ole-ocx-activex

PowerBuilder - Wikipedia, the free encyclopedia
PowerBuilder is an integrated development environment owned by Sybase , a division of SAP . It has been in use since 1991, peaking around 1998 ...

Sybase PowerBuilder tool readied for Microsoft's .Net
... Win32 or newer style .Net development After several years of work, Sybase is ready to deliver on the final step in its plan to move PowerBuilder ...

Jim O'Neil (@jimoneil) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Open Directory - Computers: Programming: Languages
about dmoz - dmoz blog - report abuse/spam - help the entire directory only in Programming/Languages Description Top : Computers : Programming ...

The HP Booth Staff (Goons) Owe Me an Apology
... when you might need to use it. For instance, when I was in the WinRunner world there were plugins for driving terminal emulators and powerbuilder ...

Contact Us - Sybase Inc
Thanks for visiting the 主页 section of Sybase.com. Here you will find information about Contact Us. For more information about Business Intelligence, ...

热门搜索 - 我的异常网
... 我的异常网 » 热门搜索 sdpnet2 移动【A111】其它用户原因鉴权失败,是什么意思啊 http:// 192.168.1.102:22578 本网站服务器位于美国,受美国法律保护 MiniUI js 破解 http://192.168.1.103:8080/ powerbuilder ...

Mobile app security: Always keep the back door locked
The best way to keep mobile apps safe is to secure the services they connect to.

10 Tech Skills That Will Instantly Net You A $100,000+ Salary
... that let's developers run Java applications. Java is highly popular language for writing web apps and custom enterprise apps. No. 8: PowerBuilder ...

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Resources last updated: 1/24/2016 1:18:43 AM