Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating data types?

Status
Not open for further replies.
VB6 allows for the definition of User Defined Data Types which are really a Structure of VB6 Native Variable Data Types.

The structure is defined through the TYPE statement which acts as a template.

Private Type udt_MyTypeAddress
strMyName as String
strMyStreet as String
strMyCityCode as String
strMyCity as String
End Type


The user definded variable you want to use in your program must then be defined as any other variable:

Dim udtAddress as udt_MyTypeAddress

From now on you can do anything you want (well almost anything) with the variable udtAddress: you can assign values to it, you can pass it to procedures, and so on ...

If, on the other hand, you want to define new native variables, such as TwentyBitsInteger, which acts as a signed Integer but with a 20-bit length, you can as far as I know NOT do it.

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Hmmmmmmmmmmmmmm,

rvbasic,

I don't QUITE agree. Yo can implement a CLASS which will "ACT" like a new type. Even your 20 Bit integer. Of course YOU would have to implement the properties and methods of the class which accomplish the variable transformations, however IF you were motivated to do so it should be quite doable. I would expect some interesting challenges in accomplishing the coersion for 'mixed mode' operations (combining the 20 bit Integer with the 'standard' numeric types, but even this should be "POSSIBLE".

On the other hand, II am not going to attempt that particular exercise just to show that it can be done.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Sure Michael, but before you make any attempt: see my signature below!

Robert _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
And, I quote myself

" ... I am not going to attempt that particular exercise ... "

Just saying it SHOULD be Possible -- NOT saying it is pratical - at least not in VB.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top