Hi all,
I try to convert VB codes to C#. I got this error "Operator '!'cannot be
applied to operand of type 'long'".
Any ideas? Why doesn't "Not SYNCHRONIZE" equivalent to "!SYNCHRONI ZE"?
Thanks,
VB:
Public Const SYNCHRONIZE = &H100000
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGH TS_ALL Or KEY_QUERY_VALUE Or
KEY_SET_VALUE Or KEY_CREATE_SUB_ KEY Or KEY_ENUMERATE_S UB_KEYS Or KEY_NOTIFY
Or KEY_CREATE_LINK ) And (Not SYNCHRONIZE))
C#:
public const long SYNCHRONIZE = 0x100000;
public const bool KEY_ALL_ACCESS = ((STANDARD_RIGH TS_ALL
| KEY_QUERY_VALUE
| KEY_SET_VALUE
| KEY_CREATE_SUB_ KEY
| KEY_ENUMERATE_S UB_KEYS
| KEY_NOTIFY
| KEY_CREATE_LINK )
& !SYNCHRONIZE); 5 3137
> Why doesn't... <snip>
Because it means something different?
! is the boolean negation operator
~ is the bitwise complement operator
Try ~SYNCHRONIZE instead
Marc
I have tried ~SYNCHRONIZE but I got this error "Cannot implicitly convert
type 'long' to 'bool'".
"Marc Gravell" wrote: Why doesn't... <snip> Because it means something different?
! is the boolean negation operator ~ is the bitwise complement operator
Try ~SYNCHRONIZE instead
Marc
That is the final assignment step; depending on what your code is trying to
do (I must admit, I'm not 100% sure from the sample alone) then you probably
need to add " != 0" or " == {the bytes you are looking for}" - the latter
may require shoving the value into a variable first.
Basically, it comes down to integer / long values deliberately not being
"true" or "false"; if VB long 0 means "false", then you probably just need
to add the != 0 explicitely.
Marc
ano wrote: I have tried ~SYNCHRONIZE but I got this error "Cannot implicitly convert type 'long' to 'bool'".
Constant KEY_ALL_ACCESS is not boolean, it is obviously a long int,
since SYNCHRONIZE is declared long. Also, when you use bitwise operators
between values, the result is not a boolean, it's an int (or long, or
uint, or something).
HTH, Tom.
Thanks, I have made a mistake.
Now I changed "bool" to "int".
Thanks a lot,
ano
"Marc Gravell" wrote: That is the final assignment step; depending on what your code is trying to do (I must admit, I'm not 100% sure from the sample alone) then you probably need to add " != 0" or " == {the bytes you are looking for}" - the latter may require shoving the value into a variable first.
Basically, it comes down to integer / long values deliberately not being "true" or "false"; if VB long 0 means "false", then you probably just need to add the != 0 explicitely.
Marc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Doug |
last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 14
Message-ID: <9DxFc.23833$bs4.23734@newsread3.news.atl.earthlink.net>
Date: Sat, 03 Jul 2004 12:27:49 GMT
NNTP-Posting-Host: 24.136.228.213
X-Complaints-To: abuse@earthlink.net
X-Trace: newsread3.news.atl.earthlink.net 1088857669 24.136.228.213 (Sat, 03 Jul 2004 05:27:49 PDT)
NNTP-Posting-Date: Sat, 03 Jul 2004 05:27:49 PDT
Organization:...
|
by: Pedro Hernandez |
last post by:
Hello!
I have some (many) text files produced on windows system that I need
to process a bit, so I wrote a perl script to do the job.
The files contains characters used in Spanish (e.g. ó, é, ñ) and they
doesn't come out right.
I use RedHat 8 and it is installed with Spanish locale. LANG is
"es_ES.UTF-8".
|
by: Andrew Hoi |
last post by:
Hi,
I have a web site that use META tag like below :
<META content=blendTrans(Duration=1.0) http-equiv=Page-Enter>
<META content=blendTrans(Duration=1.0) http-equiv=Page-Exit>
it work properly when start IE and browse in the same window,
Howeve , if press the SHIFT key and click(or right click with select "open
in new window) it to open in a new window, this effect not properly ?
|
by: aden |
last post by:
I have read the years-old threads on this topic, but I wanted to
confirm what they suggest. . .
Can the this pointer EVER point to a type different from the class that
contains the member function that the this pointer is being used in?
That is, is the type of the this pointer always determined entirely
syntactically (and never dynamically)?
Example: if a member function is invoked on an object of class Apple
(appleobj.drip_it() ),...
|
by: gary |
last post by:
Hi,
We all know the below codes are dangerous:
{
int *p = new int;
delete p;
delete p;
}
And we also know the compilers do not delete p if p==NULL.
So why compilers do not "p = NULL" automatically after programs do "delete p"?
| |
by: VB Programmer |
last post by:
I want to set the enabled property of a text box based on if a checkbox is
checked or not. This works....
txtPort.Enabled = ckDefaultPort.Checked;
But, I want the enabled property to be the opposite of the checked value.
Why doesn't this work?
txtPort.Enabled = Not ckDefaultPort.Checked;
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
If Not st1.Equals("something") then
Do Something Else
End If
if str1 != "something" Then ...
I realize that != is C# stuff and/or can be also be used in Tsql, but is
there any implementation of bang ! in VB.Net? Just checking. Any samples
appreciated.
|
by: grbgooglefan |
last post by:
I am creating functions, the return result of which I am using to make
decisions in combined expressions.
In some expressions, I would like to inverse the return result of
function.
E.g. function contains(source,search) will return true if "search"
string is found in source string.
I want to make reverse of this by putting it as:
if ( ! contains(s1,s2) ):
return 1
|
by: K Viltersten |
last post by:
The following works fine doing exactly what is supposed.
<asp:LinkButton
id="id" runat="server" Text="Text">
</asp:LinkButton>
If i change it to the following, the callback method doesn't do what it
should. In fact, as far i can see, it's not even called since the break
point doesn't kick in!
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |