By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,699 Members | 1,453 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,699 IT Pros & Developers. It's quick & easy.

C# to VB

P: n/a
Converting some code from C# to VB

C#:
public const int LOCSIG = 'P' | ('K' << 8) | (3 << 16) | (4 << 24);

Here's what I have in VB:
Public Const LOCSIG As Integer = "P"c Or ("K"c << 8) Or (3 << 16) Or (4 <<
24)

Problem is, I get an error stating that '<<' is not defined for types 'Char'
and 'Integer' on the ("K"c << 8). It works in C#, but why not in VB?
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

Have a look here:

http://msdn.microsoft.com/library/de...soperators.asp

-Mendhak
[MVP - VB]
Nov 21 '05 #2

P: n/a
Operator << is for integers, so cast characters to integer, like this:

Public Const LOCSIG As Integer = AscW("P") Or (AscW("K") << 8) Or (3 << 16)
Or (4 << 24)

C#:
public const int LOCSIG = 'P' | ('K' << 8) | (3 << 16) | (4 << 24);


Nov 21 '05 #3

P: n/a
This comes as a surprise to most people, but VB.NET with Option Strict On is
actually stricter than C#.

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"OpticTygre" wrote:
Converting some code from C# to VB

C#:
public const int LOCSIG = 'P' | ('K' << 8) | (3 << 16) | (4 << 24);

Here's what I have in VB:
Public Const LOCSIG As Integer = "P"c Or ("K"c << 8) Or (3 << 16) Or (4 <<
24)

Problem is, I get an error stating that '<<' is not defined for types 'Char'
and 'Integer' on the ("K"c << 8). It works in C#, but why not in VB?

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.