By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,204 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,204 IT Pros & Developers. It's quick & easy.

How to set a text file as the source of a text box and auto-refresh the latter?

P: 7
Hi all,

I have to use a Fortran DLL inside a VBA code in MS Access 2003. However the DLL takes quite a long time to run, and I would like it to echo a few messages while in progress.

I thought that the best way of doing it was to make the dll write its messages into a text file (something like "Processing ith data out of n..."), and then somehow write the content of the text file into a VBA Textbox. I guess that it's not too difficult doing that by setting the ControlSource property of the Textbox as some hand-made function (something like MyFunctionToReadFile(InputFile))... But how can I tell the Textbox to auto-update itself as new messages are added to the text file?

Thanks for your help!

BG
Sep 15 '08 #1
Share this Question
Share on Google+
4 Replies


FishVal
Expert 2.5K+
P: 2,653
Hello, BG.

If I've got it right you have an opportunity to make changes to the dll code.
If so you may pass to this time-consuming dll function a pointer to callback function in Access code module, thus passing messages directly to your VBA code.

Here you can find an example of VBA code running DLL function and getting data via callback.

Regards,
Fish
Sep 15 '08 #2

P: 7
Hello Fish,

thanks, it seems to be a good way of doing things. If I understand correctly, one has to pass to the dll a function pointer, and then make the dll call the function corresponding to that pointer.
This seems rather easy to do in C-type languages. However, I don't know how to handle that with my (Compaq) Fortran 90... But I guess that this goes beyond the frame of this forum. I'll dig internet to find if there is a way to do it.

Regards,
Bruno
Sep 16 '08 #3

P: 7
Got it!

Works like a charm by passing AddressOf CallbackFunc to the dll, and declare in the Fortran dll the function through as INTERFACE statement... Then I had to use some trick to pass the string from the Fortran dll to the VBA callback function, because of the different conventions for strings between the 2 languages.
Sep 16 '08 #4

FishVal
Expert 2.5K+
P: 2,653
Got it!

Works like a charm by passing AddressOf CallbackFunc to the dll, and declare in the Fortran dll the function through as INTERFACE statement...
Congratulations.

Then I had to use some trick to pass the string from the Fortran dll to the VBA callback function, because of the different conventions for strings between the 2 languages.
:)

Just few minutes ago was going to post you that VB string type convention differs from null terminated string.
Sep 16 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.