Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET's version of C#'s '|' symbol

Status
Not open for further replies.

KevoMee

Technical User
Apr 30, 2002
72
0
0
IE
Hi All,

I'm using a third party control (C1FlexGrid) and I'm looking to pass in multiple enumeration values to a function call. The C# version is:

Code:
_flex.SaveExcel(dlg.FileName, table, FileFlags.VisibleOnly | FileFlags.IncludeFixedCells);

What would the VB version be?

Regards,
 
Hey Rick,

That's what I thought but it isn't working for me...
 
Sirius, using the OR opperator in this situation should produce an integer value. It is a bitwise operator. That means that if

FileFlags.VisibleOnly = 1 (00000001)
FileFlags.IncludeFixedCells = 2 (00000010)

then

FileFlags.VisibleOnly OR FileFlags.IncludeFixedCells = 3 (00000011)

It could be trying to return a boolean value for some reason, but I haven't used this syntax much in VB, so I'm not sure how to force it to use the OR bitwise operator instead of the OR logic opertator.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
I think you guys are right (on the "OR" and "+"), I think there is an issue with the control...

Time to harrass the componentone people :)
 
SiriusBlackOp's last example (with the plus sign should work), I also use the And operator:

_flex.SaveExcel(dlg.FileName, table, FileFlags.VisibleOnly And FileFlags.IncludeFixedCells)
 
Borvik,

you've actually used this with the C1flexgrid control? It seems to have issues exporting merged & fixed cells...
 
Sorry KevoMee,

I haven't used the C1flexgrid - I just know how to combine the multiple flags, as I've done that several times during my projects.
 
The + sign will only work if they used a binary pattern for their values. MS did this with the old message box options in VB 6.

For example:
Code:
A = 1 (00000001)
B = 2 (00000010)
C = 4 (00000100)
D = 8 (00001000)

A +  B +  C +  D = 15 (00001111)
A OR B OR C OR D = 15 (00001111)



If the values do not follow a binary pattern, the behavior changes:
Code:
A = 1 (00000001)
B = 2 (00000010)
C = 3 (00000011)
D = 4 (00000100)

A +  B +  C +  D = 10 (00001010)
A OR B OR C OR D = 7  (00000111)

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
That's right Rick... though I think most of the Flag operators do follow a binary pattern (I found one that followed several binary patterns and separated the groupings by a break in the pattern).

Coincidentally, while And may work in some cases (and I was just going from memory) I found where OR does work (more than likely plenty more places - like Rick's example):

MsgBox(strMsg, MsgBoxStyle.Critical Or MsgBoxStyle.YesNo)

So try various combinations of the methods above, and you should find a method that will work for you.

I'm starting to get fuzzy now - back to playing with printers...
 
I think that for the msgbox function i user the + instead of OR. Not sure.
 
The msgbox function would work either way. I think in VB6 most people just used the + operator though. So long as the numeric values of the constants are bitmaps (a map of bits, not a .BMP file) with a single '1', adding and ORing will have the same effect.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top