Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Murray Ruggiero on November 27, 2010, 07:35:08 PM

Title: Porting advance UDT from VB 6.0
Post by: Murray Ruggiero on November 27, 2010, 07:35:08 PM

In VB 6.0 , you can define array as part of UDT and size them at runtime. That can not be done in Power Basic. The work around that I was told is to use a pointer in the UDT and size that object and runtime.  I understand the concept but am not quite sure how to do this in power basic. Can anyone show an example of a structure and supporting code fragment like this in both languages.

For example assume MyTraders is a UDT in a structure I could use

Public Type TDefine
MT() as MyTraders
Counter() as integer
End Type

In needed also show how to use arrays which are declared at runtime for standard types.

   Thanks you in advance for any help.
Title: Re: Porting advance UDT from VB 6.0
Post by: James C. Fuller on November 27, 2010, 11:37:04 PM
If using PB9/5 use a class instead of a UDT.

James
Title: Re: Porting advance UDT from VB 6.0
Post by: Murray Ruggiero on November 28, 2010, 01:11:50 AM
I am really new to PB so please explain how I would do that. Also this structure is used by many different classes which wil be exposed as Active X COM DLL's. So can you give me a brief code example ?.
Title: Re: Porting advance UDT from VB 6.0
Post by: José Roca on November 28, 2010, 02:35:31 AM
Both VB and COM use safe arrays. PB does not have native support for safe arrays, so you will have to learn how to use the safe array API functions: http://msdn.microsoft.com/en-us/library/ms221145.aspx
Title: Re: Porting advance UDT from VB 6.0
Post by: Murray Ruggiero on November 28, 2010, 06:13:00 PM
Thanks, I am a VB 6.0 programmer will safe arrays work for non standard types. I want to create UDT which contain UDT within them and the top most level contains an array of the lower level user type.

Title: Re: Porting advance UDT from VB 6.0
Post by: José Roca on November 28, 2010, 06:48:05 PM
Supported types are listed here:
http://msdn.microsoft.com/en-us/library/ms897140.aspx

For UDTs, you will have to use variants and the IRecord interface:
http://msdn.microsoft.com/en-us/library/ms221039.aspx

I don't have any example, since I never use VB.