Results 1 to 14 of 14

Thread: Anomaly click in VB6

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    6

    Anomaly click in VB6

    Hello everybody,

    So, it's my first post in this furum, and I hope that I get a solution:

    In fact, I have a probleme when I call a dll function and I see an anomaly:
    - I puted a fuction under a button
    - when I clkik on this button it seems that anithing does happen
    - but when I was a little nurvous , I clicked 6 or 7 times on the same button and WOW, it return what I expect !!!
    - it's repeatable and it's not acceptable for me and I wanna get the information from the first click

    here is the code under button

    CompleteSNR = getSerialNumberForAttrib(1, "STR1", "STR2", "STR3")
    MsgBox (CompleteSNR)



    and here is the declaration of this function :

    Declare Function getSerialNumberForAttrib Lib "C:\EnvCIM\itacDllCVI.dll" (ByVal sessionID As Integer, ByVal stationNr As String, ByVal attributeCode As String, ByVal attributeValue As String) As String

    and for informaion : the dll was developped under CVI labview

    Thank you in advance

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    6

    Re: Anomaly click in VB6

    is it may be a leak of memory ?
    if yes, how can I handel this ?

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Anomaly click in VB6

    So are you saying that you have to click the button 6 or 7 times before you see the msgbox or are you saying you always see the msgbox but it is empty or what?

    Also may help if you showed the code for the sub rather than just the one line.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    6

    Re: Anomaly click in VB6

    Quote Originally Posted by DataMiser View Post
    So are you saying that you have to click the button 6 or 7 times before you see the msgbox or are you saying you always see the msgbox but it is empty or what?

    Also may help if you showed the code for the sub rather than just the one line.
    yes, I see the msgbox only after 6 or 7 times

    its the hole code in the sub

    Code:
    Private Sub Command2_Click()
    
    CompleteSNR = getSerialNumberForAttrib(1, "STR1", "STR2", "STR3")
    
    MsgBox (CompleteSNR)
    
    
    End Sub

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Anomaly click in VB6

    Place a break point on that line that calls the getserial and run the program then see if it hits the break point when you click the button.
    If it does then hit the F8 key to step to the next line and see what happens.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    6

    Re: Anomaly click in VB6

    and the strange in this, the function works well when it returns a string in 17 characters but it produce this anomaly when it will be supposed to return a string in 27 characters ( this is a way you can think about)

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    6

    Re: Anomaly click in VB6

    Quote Originally Posted by DataMiser View Post
    Place a break point on that line that calls the getserial and run the program then see if it hits the break point when you click the button.
    If it does then hit the F8 key to step to the next line and see what happens.
    In fact I can't do the debugging ( the dll not allow me to do that: this function is proceded with another function that prepare the area for this ) . so I always generate a new exe and test the functionnality

  8. #8
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Anomaly click in VB6

    That doesn't make any sense to me. The code you have shown just calls a function there is no reason there that you should not be able to step through the code in the ide

    Another option you may consider is add some code to your program to write some data to a log file. In this case have it write something before it calls the function and after it calls the function and if you have some setup function add some logging the as well then run the program, click the button and go have a look at the log file.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    6

    Re: Anomaly click in VB6

    Quote Originally Posted by DataMiser View Post
    That doesn't make any sense to me. The code you have shown just calls a function there is no reason there that you should not be able to step through the code in the ide

    Another option you may consider is add some code to your program to write some data to a log file. In this case have it write something before it calls the function and after it calls the function and if you have some setup function add some logging the as well then run the program, click the button and go have a look at the log file.
    I did that log file, and it writes only the line before executing the function and after the executing function ( or not executed ) there is no trace.
    I guess it crached until executing ...

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Anomaly click in VB6

    That would indicate that an error is happening in your function and that your program is not handling the error.

    Try adding an error trap to the command_click sub
    Code:
    Private Sub Command2_Click()
    On Error GoTo ErrTrap
    CompleteSNR = getSerialNumberForAttrib(1, "STR1", "STR2", "STR3")
    
    MsgBox (CompleteSNR)
    Exit Sub
    ErrTrap:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description
    
    End Sub

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Anomaly click in VB6

    @DM. Could this be a problem btwn stdCall and CDecl? I don't know anything about that DLL
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #12
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Anomaly click in VB6

    I really don't know, don;t know anything about the dll either, just throwing a couple of things out there in hopes that it helps.

  13. #13
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    Re: Anomaly click in VB6

    Hello Habchi

    this spelling just dosn't look wright itacDllCVI.dll

    Declare Function getSerialNumberForAttrib Lib "C:\EnvCIM\itacDllCVI.dll" (ByVal sessionID As Integer, ByVal stationNr As String, ByVal attributeCode As String, ByVal attributeValue As String) As String
    regards
    Chris

  14. #14
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Anomaly click in VB6

    I think Lvaolpe might be on to something.

    http://www.ni.com/white-paper/3341/en/#toc2
    if you want your DLL to be called from environments such as Microsoft Visual Basic, you must declare the functions to export with the __stdcall calling convention.

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