Visio events (C# to VB translation)

S

Sorin-Emanuel

After looking at the sample OfficePlan in Visio 2003 SDK
I can't translate from C# to VB the following statements:

newEvent = documentEvents.AddAdvise(
unchecked((short)VisEventCodes.visEvtAdd) +
(short)VisEventCodes.visEvtShape),
(IVisEventProc)this, sink, targetArgs);

and the corresponding ones:

case (short)VisEventCodes.visEvtShape +
unchecked((short)VisEventCodes.visEvtAdd):

where:
VisEventCodes.visEvtShape = 64
but
VisEventCodes.visEvtAdd = 32768

Thanks,
Sorin-Emanuel
 
G

Guest

There is no direct equivalent to "unchecked" in VB.
Just do a conversion, leaving it out. You may need to adjust the type of
visEvtAdd to an integer. (download our demo at www.instantvb.com for the
conversion).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
Clear VB: Cleans up outdated VB.NET code
 
S

Sorin-Emanuel

Your demo at www.instantvb.com might be useful sometimes.
In this case the solution proposed:

'TODO: INSTANT VB TODO TASK: There is no VB.NET equivalent to
'unchecked':
'ORIGINAL LINE: newEvent =
documentEvents.AddAdvise(unchecked((short)VisEventCodes.visEvtAdd) +
(short)VisEventCodes.visEvtShape), (IVisEventProc)Me, sink,
targetArgs);
Private newEvent =
documentEvents.AddAdvise((CShort(VisEventCodes.visEvtAdd)) +
CShort(VisEventCodes.visEvtShape)), CType(Me, IVisEventProc), sink,
targetArgs)

'TODO: INSTANT VB TODO TASK: There is no VB.NET equivalent to
'unchecked':
'ORIGINAL LINE: case (short)VisEventCodes.visEvtShape +
unchecked((short)VisEventCodes.visEvtAdd):
Case CShort(VisEventCodes.visEvtShape) +
(CShort(VisEventCodes.visEvtAdd))

raise the error:
"Constant expression (VisEventCodes.visEvtAdd) not representable in
type 'Short'"

And AddAdwise:
evtObj = object.AddAdvise (eventCode, eventSink, IIDSink, targetArgs)
needs an eventCode (Short integer).

I am looking for a refinement of this idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top