• Welcome to Theos PowerBasic Museum 2017.

Porting advance UDT from VB 6.0

Started by Murray Ruggiero, November 27, 2010, 07:35:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Murray Ruggiero


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.

James C. Fuller

If using PB9/5 use a class instead of a UDT.

James

Murray Ruggiero

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 ?.

José Roca

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

Murray Ruggiero

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.


José Roca

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.