Hello,
I found some code that I could use in my application on the web, but it is
written in C#, and I would like to convert it to VB. And I am having
problems with one section. Is there anyone that could tell me how to
convert these two things?
1)
[Flags, Serializable]
public enum CardType
{
MasterCard = 0x0001,
VISA = 0x0002,
Amex = 0x0004,
DinersClub = 0x0008,
enRoute = 0x0010,
Discover = 0x0020,
JCB = 0x0040,
Unknown = 0x0080,
All = CardType.Amex | CardType.Diners Club | CardType.Discov er |
CardType.Discov er |
CardType.enRout e | CardType.JCB | CardType.Master Card | CardType.VISA
}
I understand how to do the ENUM, but I don't understand what the values are?
They seem like some kind of bit settings and I don't know how to do that.
2.)
if (_cardTypes & CardType.Amex)! =0)
where _cardTypes I believe contains some bitwise combination of the
CardTypes from above.....
Thanks for any help!
Jim 37 11032
Hi James,
1:
<Flags(), Serializable()> _
Public Enum CardType
MasterCard = &H1
VISA = &H2
Amex = &H4
DinersClub = &H8
enRoute = &H10
Discover = &H20
JCB = &H40
Unknown = &H80
All = MasterCard Or VISA Or Amex Or DinersClub Or enRoute Or Discover Or
JCB
End Enum
2:
If (_cardTypes And CardType.Amex) = CardType.Amex Then
' Amex is present
End If
--
HTH,
-- Tom Spink, Über Geek
Please respond to the newsgroup,
so all can benefit
"Maybe it's a game called 'Punish the User'"
"James Radke" <jr*****@wi.rr. com> wrote in message
news:ub******** ******@TK2MSFTN GP11.phx.gbl...
: Hello,
:
: I found some code that I could use in my application on the web, but it is
: written in C#, and I would like to convert it to VB. And I am having
: problems with one section. Is there anyone that could tell me how to
: convert these two things?
:
: 1)
:
: [Flags, Serializable]
: public enum CardType
: {
: MasterCard = 0x0001,
: VISA = 0x0002,
: Amex = 0x0004,
: DinersClub = 0x0008,
: enRoute = 0x0010,
: Discover = 0x0020,
: JCB = 0x0040,
: Unknown = 0x0080,
: All = CardType.Amex | CardType.Diners Club | CardType.Discov er |
: CardType.Discov er |
: CardType.enRout e | CardType.JCB | CardType.Master Card | CardType.VISA
: }
:
:
: I understand how to do the ENUM, but I don't understand what the values
are?
: They seem like some kind of bit settings and I don't know how to do that.
:
: 2.)
:
: if (_cardTypes & CardType.Amex)! =0)
:
: where _cardTypes I believe contains some bitwise combination of the
: CardTypes from above.....
:
: Thanks for any help!
:
: Jim
:
:
Hello,
"James Radke" <jr*****@wi.rr. com> schrieb: 1)
[Flags, Serializable] public enum CardType { MasterCard = 0x0001, VISA = 0x0002, Amex = 0x0004, DinersClub = 0x0008, enRoute = 0x0010, Discover = 0x0020, JCB = 0x0040, Unknown = 0x0080, All = CardType.Amex | CardType.Diners Club | CardType.Discov er | CardType.Discov er | CardType.enRout e | CardType.JCB | CardType.Master Card | CardType.VISA }
I understand how to do the ENUM, but I don't understand what the values are?
They are in hexadezimal format. Use '&H1' for '0x0001', '&H2' for '0x0002'
and so on.
2.)
if (_cardTypes & CardType.Amex)! =0)
where _cardTypes I believe contains some bitwise combination of the CardTypes from above.....
Use 'If (m_CardTypes And CardType.Amex) <> 0 Then' instead.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
Tom,
Hmmm... So the All = in #1 below would use the 'Or' versus the 'Xor'? Does
a standard Or make ALL a unique ENUM? Or is that doing something slightly
different in VB, than in the C#?
I will try it! Thanks for the assist.......
Jim
"Tom Spink" <th**********@n tlworld.com> wrote in message
news:uW******** ******@TK2MSFTN GP09.phx.gbl... Hi James,
1:
<Flags(), Serializable()> _ Public Enum CardType MasterCard = &H1 VISA = &H2 Amex = &H4 DinersClub = &H8 enRoute = &H10 Discover = &H20 JCB = &H40 Unknown = &H80 All = MasterCard Or VISA Or Amex Or DinersClub Or enRoute Or Discover
Or JCB End Enum
2:
If (_cardTypes And CardType.Amex) = CardType.Amex Then ' Amex is present End If
-- HTH, -- Tom Spink, Über Geek
Please respond to the newsgroup, so all can benefit
"Maybe it's a game called 'Punish the User'"
"James Radke" <jr*****@wi.rr. com> wrote in message news:ub******** ******@TK2MSFTN GP11.phx.gbl... : Hello, : : I found some code that I could use in my application on the web, but it
is : written in C#, and I would like to convert it to VB. And I am having : problems with one section. Is there anyone that could tell me how to : convert these two things? : : 1) : : [Flags, Serializable] : public enum CardType : { : MasterCard = 0x0001, : VISA = 0x0002, : Amex = 0x0004, : DinersClub = 0x0008, : enRoute = 0x0010, : Discover = 0x0020, : JCB = 0x0040, : Unknown = 0x0080, : All = CardType.Amex | CardType.Diners Club | CardType.Discov er | : CardType.Discov er | : CardType.enRout e | CardType.JCB | CardType.Master Card | CardType.VISA : } : : : I understand how to do the ENUM, but I don't understand what the values are? : They seem like some kind of bit settings and I don't know how to do
that. : : 2.) : : if (_cardTypes & CardType.Amex)! =0) : : where _cardTypes I believe contains some bitwise combination of the : CardTypes from above..... : : Thanks for any help! : : Jim : :
Hi James,
VB's AND is a bitwise And and OR is a bitwise Or. They are the same as
their C# counterparts.
If you come across && in some C# code, it is the same as VB's AndThen.
Similarly C#'s || is the same as VB's OrElse.
Regards,
Fergus
MVP [Windows Start button, Shutdown dialogue]
Hello,
"Fergus Cooney" <fi******@tesco .net> schrieb: If you come across && in some C# code, it is the same as VB's AndThen.
'AndThen'? Typo or am I missing something?
;-)
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
Herfried,
Yes I too find these operators not nice Herfried,
In Dutch there is a proverbial: That is grist for his mill.
:-))
Cor
Hello,
"Cor" <no*@non.com> schrieb: Yes I too find these operators not nice Herfried, In Dutch there is a proverbial: That is grist for his mill.
'AndAlso' and 'OrElse' -- IMO very nice. I would have liked 'And' and 'Or'
as logical operators and 'BitAnd' and 'BitOr' as bitwise operators, but they
changed that in the Beta.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
Hi Herfried,
When the names where "BitAnd" and "BitOr" I would never argue about it.
Cor
Hello,
"Cor" <no*@non.com> schrieb: When the names where "BitAnd" and "BitOr" I would never argue about it.
You vote for 'Bit'x operators too?
;-)
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael B. Trausch |
last post by:
I have a question regarding bitwise operators, I've been trying to
figure this out for about two days now, and I just can't seem to get it.
What I'm trying to do is use a variable to hold a bitmask of 'flags'
for users on a website. The function below is supposed to be a search
function for one of those flags in a particular thing.
The...
|
by: aiKeith |
last post by:
Does someone know the equivelant to this in vb.net?
c#
if ( (someChar & 0xFF80 ) == 0){
// Evaluated, do something....
}
How can i accomplish this in vb.net? If you could tell me and also explain
the logic, I would be appreciative...
|
by: Mike Hodkin |
last post by:
As a beginning student of C++, books reference "bitwise operators" and give
brief examples, but I have not read a good explanation of what they are used
for. One reference mentioned that they are used in hardware programming.
Are they used very often in routine C/C++ programming, and what for?
thanks,
MJH
|
by: jas_lx |
last post by:
The basic understanding of what bitwise operators (& ^ | >> << ) comes
fairly simple, as long as one has a fundamental understanding of bits,
bytes and binary.
Having done some Win32 programming in straight C, the Win32 API sends
windows messages to applications with various settings stored in bit
fields, in which case changing the...
|
by: Steve Summit |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
It's often explained that the reason for some of the imprecision
in C's definition is so that C can be implemented on different
kinds of machines -- say, those with 2's complement,
1's complement, or sign-magnitude arithmetic. But the followup
remark is sometimes also made that the choice of arithmetic...
| |
by: noridotjabi |
last post by:
I'm learning to program in C and any tutorial or book that I read likes
to briefly touch on birdies operators and then move on without giving
any sort of example application of them. Call me what you will but I
cannot seem to see the purpose for bitwise operators. Especially the
operators bitwise OR ( | ) and bitwise AND ( & ), I'm just not...
|
by: Bob Homes |
last post by:
In VB6, foreground and background colors of controls had to be assigned a
single number. If you knew the RGB values for the color, you still had to
convert them into the single number accepatable to the VB6 controls.
In VB.NET, you can't set colors that way anymore, now you have to use a
"color". There is a way to convert RGB values to a...
|
by: Mark Rae |
last post by:
Hi,
This isn't *specifically* an ASP.NET question, so I've also posted it in the
ADO.NET group - however, it's not too far off-topic...
Imagine a SQL Server 2005 database with a table with an int column used for
bitwise data - you know the sort of thing... 0, 1, 2, 4, 8, 16 etc
intBitwise strName
----------------------
|
by: Santhosh |
last post by:
Hi to all,
How the individual digits of a number can be obtained using the
bitwise operators alone.Is it possible to do it ?
If we have n = 34
Result has to be 3,4.
Thanks a billion for your reply in advance.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |