Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

access versione 32 / 64 bit come gestirle da vba

121 views
Skip to first unread message

mario rossi

unread,
Jun 8, 2022, 3:24:48 AM6/8/22
to
buongiorno a tutti, esiste un modo per gestire da vba la definizione delle function e sub per via del fatto che nella 64 va aggiunta la scritta PTRSAFE nella definizione?

Grazie a tutti.

BFS

unread,
Jun 8, 2022, 3:41:41 AM6/8/22
to
Il 08/06/2022 09:24, mario rossi ha scritto:
> buongiorno a tutti, esiste un modo per gestire da vba la definizione delle function e sub per via del fatto che nella 64 va aggiunta la scritta PTRSAFE nella definizione?
>
> Grazie a tutti.


https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/ptrsafe-keyword

BFS

mario rossi

unread,
Jun 8, 2022, 4:14:50 AM6/8/22
to
#If VBA7 Then
Declare PtrSafe Sub...
#Else
Declare Sub...
#EndIf

anche per ogni function o solo per le sub?

@Alex

unread,
Jun 8, 2022, 5:28:26 AM6/8/22
to
Argomento già trattato... e banalizzato da chi per poca competenza, non aveva capito...!
La gestione della Formattazione condizionale deve applicarsi a TUTTE le parti coinvolte non solo alle dichiarazioni API, ma anche alle Funzioni standard se prevedono Parametri condizionati o a Dati di tipo Strutturati o a dichiarazioni EMUM...

Esempio stupido, questa funziona solo se 32Bit:
Function GetHandle(frm As Access.Form) As Long
Dim mhWnd As Long
GetHandle=frm.hWnd
End Function

Questa funziona sempre:
#If VBA7 Then
Function GetHandle(frm As Access.Form) As LongPtr
Dim mhWnd As LongPtr
GetHandle=frm.hWnd
End Function
#Else
Function GetHandle(frm As Access.Form) As Long
Dim mhWnd As Long
GetHandle=frm.hWnd
End Function
#EndIf

Se hai una Structure, che per le API sono ricorrenti:

Public Type myType
MyName As String
hWnd As Long <----- Questa va condizionata
x As Long
End Type

Public Type myType
MyName As String
#If VBA7 Then
hWnd As LongPtr
#Else
hWnd As Long
#End If
x As Long
End Type

ecc...!

Saluti
@Alex
0 new messages