Quante volte vi è capitato di voler passare UDT a classi?Ma non si poteva.
Basta semplicemente usare i puntatori e il gioco è fatto.
Naturalmente gli udt non devono contenere stringhe di lunghezza variabile, e devono essere dichiarati nei moduli in cui si vogliono usare.
Es:
Class1:
Option Explicit
Private Type tUtente
Nome As String * 25
Cognome As String * 25
End Type
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Public Sub MessaggioUtente(ByVal ptrUtente As Long)
Dim U As tUtente
CopyMemory ByVal VarPtr(U), ByVal ptrUtente, LenB(U)
MsgBox RTrim(U.Nome) & RTrim(U.Cognome)
End Sub
Form1:
Option Explicit
Private Type tUtente
Nome As String * 25
Cognome As String * 25
End Type
Private Sub Form_Load()
Dim U As tUtente
Dim Prova As New Class1
U.Nome = "VB"
U.Cognome = "Extreme"
Prova.MessaggioUtente VarPtr(U)
End Sub
Per ulteriori chiarimenti sono qui ciauz