[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What is the "When" keyword in VB6 and a replacement for VarPtr

Posted on 2009-12-16
8
Medium Priority
?
407 Views
Last Modified: 2012-05-08
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?
0
Comment
Question by:bill_home
  • 4
  • 4
8 Comments
 
LVL 4

Accepted Solution

by:
Geoff Bryan earned 2000 total points
ID: 26063746
For VarPtr see

http://dotnet-snippets.com/dns/varptr-for-net-SID585.aspx

As far as I know 'When' is not a VB6 keyword and so it must represent a variable or a developer written function somewhere in the code.

0
 

Author Comment

by:bill_home
ID: 26064021
I have never seen it before. It is used all over this project I am converting. It compiles in vb6 and runs fine. I am hoping someone may have seen it. I will check out your link, thanks.
0
 
LVL 4

Expert Comment

by:Geoff Bryan
ID: 26064140
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:bill_home
ID: 26064173
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
0
 
LVL 4

Expert Comment

by:Geoff Bryan
ID: 26064414
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
0
 
LVL 4

Expert Comment

by:Geoff Bryan
ID: 26064526
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
0
 

Author Comment

by:bill_home
ID: 26064544
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
0
 

Author Closing Comment

by:bill_home
ID: 31666822
quick response and right on the $$$$.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question