-
Jun 22nd, 2017, 06:29 AM
#1
Thread Starter
New Member
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
-
Jun 22nd, 2017, 07:57 AM
#2
Thread Starter
New Member
Re: Anomaly click in VB6
is it may be a leak of memory ?
if yes, how can I handel this ?
-
Jun 22nd, 2017, 08:03 AM
#3
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.
-
Jun 22nd, 2017, 08:27 AM
#4
Thread Starter
New Member
Re: Anomaly click in VB6
Originally Posted by DataMiser
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
-
Jun 22nd, 2017, 08:32 AM
#5
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.
-
Jun 22nd, 2017, 08:36 AM
#6
Thread Starter
New Member
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)
-
Jun 22nd, 2017, 08:39 AM
#7
Thread Starter
New Member
Re: Anomaly click in VB6
Originally Posted by DataMiser
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
-
Jun 22nd, 2017, 09:00 AM
#8
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.
-
Jun 22nd, 2017, 09:26 AM
#9
Thread Starter
New Member
Re: Anomaly click in VB6
Originally Posted by DataMiser
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 ...
-
Jun 22nd, 2017, 09:44 AM
#10
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
-
Jun 22nd, 2017, 10:18 AM
#11
Re: Anomaly click in VB6
@DM. Could this be a problem btwn stdCall and CDecl? I don't know anything about that DLL
-
Jun 22nd, 2017, 11:41 AM
#12
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.
-
Jun 22nd, 2017, 11:54 AM
#13
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
-
Jun 22nd, 2017, 12:51 PM
#14
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|