Hello everybody, I tried to code the GETENUMdll subroutine in the VBA development environment of an Excel spreadsheet. Thank you for your help.
Steps to Reproduce
Expected behavior: As I set the hEnum variable to a string with the indication of the units system (such as "SI"), and run it through the GETENUMdll subroutine, I expect the output variable iEnum to give back the correspondent number. The code I'm using is posted below, in the additional information section.
Actual behavior: When the subroutine is called, Excel crashes
Versions
REFPROP Version: [REFPROP10] Operating System and Version: [Windows10] Access Method: [VBA Excel in MS Office 2019]
Additional Information
==========================VBA CODE===================
Public Declare Sub GETENUMdll Lib "REFPROP.DLL" (iFlag As Long, hEnum As String, iEnum As Long, ierr As Long, herr As String, hEnum_length As Long, herr_length As Long)
Public herr As String * 255
Public hEnum As String, ierr As Long, iEnum As Long
You also need to expand the size of the buffer for hEnum to 255, you have currently passed in a three character string (two characters plus the NULL character)
Description
Hello everybody, I tried to code the GETENUMdll subroutine in the VBA development environment of an Excel spreadsheet. Thank you for your help.
Steps to Reproduce
Expected behavior: As I set the hEnum variable to a string with the indication of the units system (such as "SI"), and run it through the GETENUMdll subroutine, I expect the output variable iEnum to give back the correspondent number. The code I'm using is posted below, in the additional information section.
Actual behavior: When the subroutine is called, Excel crashes
Versions
REFPROP Version: [REFPROP10]
Operating System and Version: [Windows10]
Access Method: [VBA Excel in MS Office 2019]
Additional Information
==========================VBA CODE=================== Public Declare Sub GETENUMdll Lib "REFPROP.DLL" (iFlag As Long, hEnum As String, iEnum As Long, ierr As Long, herr As String, hEnum_length As Long, herr_length As Long)
Public herr As String * 255 Public hEnum As String, ierr As Long, iEnum As Long
Function get_units()
hEnum = "SI" iEnum = 0 Call GETENUMdll(1, hEnum, iEnum, ierr, herr, 255, 255) MsgBox (iEnum)
End Function