473,890 Members | 1,176 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Uint in VB .NET

C# allows one to specify a constant with a type of uint, so you could have,
say:

private const uint varname = 0xFFFFFFF0

How does one port such statements to VB .NET?

--
http://www.standards.com/; See Howard Kaikow's web site.
Nov 21 '05 #1
6 12925
"Howard Kaikow" <ka****@standar ds.com> schrieb:
C# allows one to specify a constant with a type of uint, so you could
have,
say:

private const uint varname = 0xFFFFFFF0

How does one port such statements to VB .NET?


Currently that's not supported by VB.NET because VB.NET doesn't "natively"
support unsigned types (notice that the unsigned types are not CLS
compliant).

Untested:

\\\
Private ReadOnly varname As UInt32 = _
Convert.ToUInt3 2(&HFFFFFFF0)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
I had tried something like that.

Error returned is "Value was either too large or too small for a UInt32."

The only things that "work" are

Private ReadOnly varname As Integer = &HFFFFFFF0
Const zz As Integer = &HFFFFFFF0

--
http://www.standards.com/; See Howard Kaikow's web site.
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:eH******** ******@tk2msftn gp13.phx.gbl...
"Howard Kaikow" <ka****@standar ds.com> schrieb:
C# allows one to specify a constant with a type of uint, so you could
have,
say:

private const uint varname = 0xFFFFFFF0

How does one port such statements to VB .NET?


Currently that's not supported by VB.NET because VB.NET doesn't "natively"
support unsigned types (notice that the unsigned types are not CLS
compliant).

Untested:

\\\
Private ReadOnly varname As UInt32 = _
Convert.ToUInt3 2(&HFFFFFFF0)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Even if you get any of these variations to actually compile, it is still of
little use.
While VB.Net (pre 2005) does allow you to declare Unsigned Ints, there are
no operators.
You can add, subtract, etc. not even within the same data type.
Even simple compares will choke in many cases.

Gerald
Nov 21 '05 #4
that should read...
You can "NOT" add, subtract, etc...

"Gerald Hernandez" <Cablewizard@sp *********@Yahoo .com> wrote in message
news:uq******** ******@tk2msftn gp13.phx.gbl...
Even if you get any of these variations to actually compile, it is still of little use.
While VB.Net (pre 2005) does allow you to declare Unsigned Ints, there are
no operators.
You can add, subtract, etc. not even within the same data type.
Even simple compares will choke in many cases.

Gerald

Nov 21 '05 #5
"Gerald Hernandez" <Cablewizard@sp *********@Yahoo .com> wrote in message
news:uq******** ******@tk2msftn gp13.phx.gbl...
Even if you get any of these variations to actually compile, it is still of little use.
While VB.Net (pre 2005) does allow you to declare Unsigned Ints, there are
no operators.
You can add, subtract, etc. not even within the same data type.
Even simple compares will choke in many cases.


I understood that.

Fer now, I'm just passing a constant to a sub/function, so I can get by
cheating with Integer.
Nov 21 '05 #6

"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
"Gerald Hernandez" <Cablewizard@sp *********@Yahoo .com> wrote in message
news:uq******** ******@tk2msftn gp13.phx.gbl...
Even if you get any of these variations to actually compile, it is still

of
little use.
While VB.Net (pre 2005) does allow you to declare Unsigned Ints, there are no operators.
You can add, subtract, etc. not even within the same data type.
Even simple compares will choke in many cases.


I understood that.

Fer now, I'm just passing a constant to a sub/function, so I can get by
cheating with Integer.


As long as you resign yourself to using bit-wise operations only, then this
is your best bet. It is what I do, and it works quite well. If you need that
extra top bit, then the best thing to do is work with a Long (Int64).
Sometimes that extra bit is all you really need, it seems a shame to waste
another 32. But hopefully this will be solved with VB 2005.

Gerald
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8873
by: pvdm | last post by:
Hi, I am writing an app which encapsulates a multimedia timer. I implemented a TimerProc as static member function and a static member variable pThis as pseudo this variable to access in the static TimerProc function. timeSetEvent uses TimerProc to set the callback function.
2
5959
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using X509Certificate ( *.cer file ) so that it can be used to email as attachment. The real part is Encrypting using X509Certificate and CryptoServiceProvider.
4
10505
by: Oliver | last post by:
Hello ! I am trying to get the unrar.dll working in C#... it seems that I correctly imported the functions as the first 2 function work without problem (RAROpenArchive & RARGetDLLVersion)... however always if I want to execute the RARReadHeader Function I get "Object reference not set to an instance of an object" What do I wrong, I used the unrar.dll documentation and I really dont find any mistakes but why do I always get this error...
5
9115
by: Ken | last post by:
Hello All, I am hoping someone has used the windows GDI AddPrinter API. What I need to know is how the private static extern bool GetPrinter(IntPtr hPrinter, Int32 dwLevel, IntPtr pPrinter, Int32 dwBuf, out Int32 dwNeeded);
2
10536
by: mmmobasher | last post by:
Dear sirs after some googling i found some code to using unrar.dll, but i get runtime error System.NullReferenceException in line iStatus=RARReadHeader(lHandle, ref uHeader); hear is the code using System; using System.Runtime.InteropServices;
47
3551
by: Bonj | last post by:
I downloaded the gzlib library from zlib in order to do compression. (http://www.gzip.org/zlib) The prototype of the compression function seems to be int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); It is meant to be called by C, but I would rather use it from C#. So I wrote the following C# program to test it, but it failed to work. The call to compress doesn't return or throw an exception, it simply...
4
7719
by: Jerry | last post by:
I am trying to read a physical sector off of the disk (the boot sector for drive C:) from C#. I have no problems doing it from a C/C++ application using the Win32 API CreateFile and ReadFile. However, when I attempt to use PInvoke to do the very same thing in C# the data read in is somehow being altered from what is on disk. Several of the bytes are being changed from their original value to 0x3f!?!?! Anyone have any ideas as to what I...
0
2060
by: Guy Mahieu | last post by:
Hi, I am trying to dynamically add menu items to external win32 applications from c# code. I have found some VB6 examples on the net that do just that, but when I rewrite them into c# they will either do nothing, add a separator or add an empty menu item which does not trigger commands when clicked. The difference between a separator or an empty item getting inserted lies in supplying the fMask of the MENUITEMINFO with the MF_OWNERDRAW...
3
5515
by: Charles Denny | last post by:
I'm trying to call CertFindCertificateInStore to find all certificates in the store that have the Code Signing enhanced key usage. I'm running into problems marshalling the array of OIDs in _CTL_USAGE. I keep getting a "This type can not be marshalled as a structure field." Does anyone have any ideas as to what I'm doing wrong? Here's the code: namespace CertSignTest { using System;
9
2637
by: Sarath | last post by:
Why the following happening? UINT m_uArrXpos; UINT **p = m_uArrXposSchema; // Failed to compile UINT **p = (UINT**)m_uArrXposSchema; // Success compilation
0
9978
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9820
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,...
0
10812
jinu1996
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...
1
10922
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,...
0
10462
tracyyun
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...
1
8016
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4676
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
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.