Results 1 to 7 of 7

Thread: ActiveX exe... (exe problem) [SOLVED]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    ActiveX exe... (exe problem) [SOLVED]

    Hi...

    I've made an ActiveX exe called MikeClasses, currentrly with one class in it, and a test progam to test my ActiveX.

    The problem is that when I compile the ActiveX and run my test program, the CPU goes to 95% and it does nothing... (And my test program DOES have a reference to the AcriveX exe)

    But... when I run the ActiveX from another instance of VB, it works perfectly... (This time, my test program has a reference to the MikeClasses.VBP project)

    Anyone had this problem that knows how to fix it ?
    How can I get it to work when the ActiveX is compiled ?

    Thanks
    Last edited by CVMichael; Jan 2nd, 2003 at 03:59 AM.

  2. #2
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Try writing a simple Log() function (or use the App object's built in logging function) and putting calls to the log code in your class. Log when you enter and exit functions, when you enter loops, and so on. Then compile and run the program and use the generated log to figure out where its getting stuck. Once you have that nailed down, post the code and I'll take a look [or just figure it out on your own if its simple].
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    Ok.... it's a bit odd, because it does not make sense to get stuck in the exe and not in the VB environment...

    Anyways... I did the log thing, and I found the function where it stops...
    VB Code:
    1. Private Type WordType
    2.     Word As String
    3.     Occ As Integer
    4. End Type
    5.  
    6. Private Function ExtractKeywords(ByRef Str As String) As String
    7.     Dim AR() As String, WA() As WordType, IND As Variant
    8.     Dim K As Long, Keywords As String
    9.    
    10.     If Str = "" Then Exit Function
    11. SEvent 18
    12.     AR = Split(Str, " ")
    13.     For Each IND In AR
    14.         If CStr(IND) <> "" Then
    15.             On Error GoTo Err_Resize
    16.             For K = 0 To UBound(WA)
    17.                 If StrComp(IND, WA(K).Word, vbTextCompare) = 0 Then Exit For
    18.             Next K
    19.            
    20.             If K > UBound(WA) Then
    21.                 If WA(UBound(WA)).Word <> "" Then ReDim Preserve WA(UBound(WA) + 1)
    22.                 WA(UBound(WA)).Word = IND
    23.             Else
    24.                 WA(K).Occ = WA(K).Occ + 1
    25.             End If
    26.             On Error GoTo 0
    27.         End If
    28.     Next IND
    29. SEvent 19
    30.     Erase AR
    31.    
    32.     QuickSort WA, LBound(WA), UBound(WA)
    33. SEvent 20
    34.     For K = UBound(WA) To LBound(WA) Step -1
    35.         Keywords = Keywords & " " & WA(K).Word
    36.     Next K
    37. SEvent 21
    38.     ExtractKeywords = Keywords
    39.     Exit Function
    40. Err_Resize:
    41.     If Err.Number = 9 Then
    42.         ReDim WA(0)
    43.         Resume Next
    44.     End If
    45. End Function

    The SEvent # is the function that writes the log.... it goes up to event 18, it never reaches 19...

    But... i really don't understand... it works perfectly in VB environment...

  4. #4
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    OK.. try dropping in a few MsgBox calls at various points, like inside your loop, in the error handler, etc. and watch the behavior of the function. Try and figure out if its getting in an infinite loop, or stuck in the error handler, or what.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    I've added more events to log, it's a bit more confuzing now...
    VB Code:
    1. Private Function ExtractKeywords(ByRef Str As String) As String
    2.     Dim AR() As String, WA() As WordType, Q As Long
    3.     Dim K As Long, Keywords As String
    4.    
    5.     If Str = "" Then Exit Function
    6. SEvent 18
    7.     AR = Split(Str, " ")
    8. SEvent 19
    9. SEvent UBound(AR)
    10.     For Q = 0 To UBound(AR)
    11. SEvent 40
    12.         If CStr(AR(Q)) <> "" Then
    13.             On Error GoTo Err_Resize
    14. SEvent 41
    15.             For K = 0 To UBound(WA)
    16. SEvent 50
    17. SEvent UBound(WA)
    18.                 If StrComp(AR(Q), WA(K).Word, vbTextCompare) = 0 Then
    19. SEvent 60
    20.                     Exit For
    21.                 End If
    22. SEvent 51
    23.             Next K
    24. SEvent 42
    25.             If K > UBound(WA) Then
    26.                 If WA(UBound(WA)).Word <> "" Then ReDim Preserve WA(UBound(WA) + 1)
    27.                 WA(UBound(WA)).Word = AR(Q)
    28.             Else
    29.                 WA(K).Occ = WA(K).Occ + 1
    30.             End If
    31. SEvent 43
    32.             On Error GoTo 0
    33.         End If
    34. SEvent 44
    35.     Next Q
    36. SEvent 20
    37.     Erase AR
    38.    
    39.     QuickSort WA, LBound(WA), UBound(WA)
    40. SEvent 21
    41.     For K = UBound(WA) To LBound(WA) Step -1
    42.         Keywords = Keywords & " " & WA(K).Word
    43.     Next K
    44. SEvent 22
    45.     ExtractKeywords = Keywords
    46.    
    47.     Exit Function
    48. Err_Resize:
    49. SEvent 30
    50.     If Err.Number = 9 Then
    51.         ReDim WA(0)
    52. SEvent 31
    53.         Resume Next
    54.     End If
    55. End Function

    And this is the output I get...

    EVENT ID: 18
    EVENT ID: 19
    EVENT ID: 342
    EVENT ID: 40
    EVENT ID: 41
    EVENT ID: 30
    EVENT ID: 31
    EVENT ID: 50
    EVENT ID: 0
    EVENT ID: 51
    EVENT ID: 50
    EVENT ID: 0
    EVENT ID: 51
    EVENT ID: 50
    EVENT ID: 0
    EVENT ID: 51
    EVENT ID: 50
    EVENT ID: 0
    EVENT ID: 51
    EVENT ID: 50
    EVENT ID: 0
    EVENT ID: 51
    EVENT ID: 50
    EVENT ID: 0
    EVENT ID: 51

    And it reapeats this to the infinite... (until I Ctrl+Alt+Del and stop the exe)

    EVENT ID: 50
    EVENT ID: 0
    EVENT ID: 51

    Now when you have a for loop "For K = 0 To 0" isn't it supposed to STOP !!!

    What's going on ???

  6. #6
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Strange... are you compiling with something like "remove array bounds checks" or some other optimizations? Sometimes those can cause odd behavior..
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    I fixed it !!!

    And no... no optimizations... I've left the defaults actually (i've only changed the ActiveX exe to "Thread per Object" setting, that's the only setting i've changed.

    I declared a long variable UB and I assigned the upper bound before the for loop. That fixed the problem, now my exe runs the same way as if in the VB environment.

    But.... this was the strangest problem I've ever had since I program in VB (for 5 years)

    VB Code:
    1. Private Function ExtractKeywords(ByRef Str As String) As String
    2.     Dim AR() As String, WA() As WordType, Q As Long, UB As Long
    3.     Dim K As Long, Keywords As String
    4.    
    5.     If Str = "" Then Exit Function
    6.    
    7.     AR = Split(Str, " ")
    8.    
    9.     For Q = 0 To UBound(AR)
    10.         If CStr(AR(Q)) <> "" Then
    11.             On Error GoTo Err_Resize
    12.            
    13.             UB = UBound(WA)
    14.             For K = 0 To UB
    15.                 If StrComp(AR(Q), WA(K).Word, vbTextCompare) = 0 Then Exit For
    16.             Next K
    17.            
    18.             If K > UBound(WA) Then
    19.                 If WA(UBound(WA)).Word <> "" Then ReDim Preserve WA(UBound(WA) + 1)
    20.                 WA(UBound(WA)).Word = AR(Q)
    21.             Else
    22.                 WA(K).Occ = WA(K).Occ + 1
    23.             End If
    24.            
    25.             On Error GoTo 0
    26.         End If
    27.     Next Q
    28.  
    29. ' the rest of the code.....

    Thanks for your help, mlewis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width