I recently had the same problem with another heavily subclassed project, andQuote:> I'm currently working on a project that incorporates Visual Basic V6.00
> interacts with Visual C++ V6.00 engine in COM (VB is the client
> the engine is the server).
> The GUI application receives callbacks from the engine.
> One of the callbacks is call 'LoadData', in-which a command-button control
> gets a focus:
> At this specific location, the application crashes with exception
> which means 'Floating-point inexact result.'
> I've searched Microsoft KB for this case and encountered a problem with
> control, yet we do not use it at our project.
> I also tried to locate any events that might occur due to 'SetFocus' (such
> and control_LostFocus and other hooks in the program).
> There wasn't any problems with either events.
> The project is working in Microsoft Windows 2000, SP3 environment,
> Microsoft Visual Studio V6.00, SP4.
eventually tracked it down to something completely different (A file
couldn't be found or something completely unrelated to floating point
values.) It turns out that the error was being scrambled by VB, and this is
a 'default' error message when something internally within VB goes wrong,
you can find more details in this KB article:
The SetFocus() method is sometimes somewhat picky though about where it can
be called, make sure that the button is visible and enabled before calling
the method (Or just error trap it.)
Alternatively go the API route and set the focus manually:
Private Declare Function SetFocusAPI Lib "user32" Alias _
"SetFocus" (ByVal hWnd As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByRef lParam As Any) As Long
Private Const WM_SETFOCUS As Long = &H7
Call SendMessage(CmdFocus.hWnd, WM_SETFOCUS, 0, ByVal 0&)
Hope this helps,
- Microsoft Visual Basic MVP -