bill_home
asked on
What is the "When" keyword in VB6 and a replacement for VarPtr
Hello All,
I am converting a VB6 app to vb.net. I came across the code listed below for a "WHEN" statement. I also need a replacement for VarPtr. I read that the "WHEN" is used like a try catch. However it does not seem to make much sense as used below. Below is the VB6 code for the "WHEN" and "VarPtr".
If When And MSG_BEFORE Then ' how would I convert this to vb.net?
zAddMsg(uMsg, IDX_BTABLE)
End If
FileWrite(hFOut, VarPtr(lngDataID), 4) 'how would I convert this to vb.net?
I am converting a VB6 app to vb.net. I came across the code listed below for a "WHEN" statement. I also need a replacement for VarPtr. I read that the "WHEN" is used like a try catch. However it does not seem to make much sense as used below. Below is the VB6 code for the "WHEN" and "VarPtr".
If When And MSG_BEFORE Then ' how would I convert this to vb.net?
zAddMsg(uMsg, IDX_BTABLE)
End If
FileWrite(hFOut, VarPtr(lngDataID), 4) 'how would I convert this to vb.net?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you Shift..F2 on the 'When', does it take you to the definition of a variable or function? It must be defined somewhere or the project wouldn't compile.
ASKER
It is not var or function in the code. Here is another example. I have not tested the Varptr part yet. Looks good though I will assign points if/when the "WHEN" is answered.
Thanks for the Help
Bill
Thanks for the Help
Bill
Hi Bill
Are you using Option Explicit in the VB6 project? If not, the 'When's will compile OK as variables (Variant), even though they are never explicitly declared with Dim. The snippet you included in your original post appears to expect When to be a boolean variable and the 'message' will be added if When is True and MSG_BEFORE is also True.
I think you missed out the second example in your latest post!
Geoff
Are you using Option Explicit in the VB6 project? If not, the 'When's will compile OK as variables (Variant), even though they are never explicitly declared with Dim. The snippet you included in your original post appears to expect When to be a boolean variable and the 'message' will be added if When is True and MSG_BEFORE is also True.
I think you missed out the second example in your latest post!
Geoff
Hi Bill
There is a WHEN keyword in VB.NET, which varies a Catch statement to only catch exceptions when the expression that follows it is True.
As there is no Try Catch structure in VB6, the When in your code can only be a variable - there is certainly no When keyword in VB6
Geoff
There is a WHEN keyword in VB.NET, which varies a Catch statement to only catch exceptions when the expression that follows it is True.
As there is no Try Catch structure in VB6, the When in your code can only be a variable - there is certainly no When keyword in VB6
Geoff
ASKER
You are absolutely correct there is no when in vb6. I did miss putting in the example. I think that there was just a bug in the origional code.
Thanks
BIll
Thanks
BIll
ASKER
quick response and right on the $$$$.
ASKER