Click here to Skip to main content
16,007,610 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralGet Hard disc Serial number Pin
Rupesh Kumar Swami19-Mar-08 6:31
Rupesh Kumar Swami19-Mar-08 6:31 
AnswerRe: Get Hard disc Serial number Pin
Rajesh Anuhya19-Mar-08 19:13
professionalRajesh Anuhya19-Mar-08 19:13 
GeneralRe: Get Hard disc Serial number Pin
Rupesh Kumar Swami20-Mar-08 3:42
Rupesh Kumar Swami20-Mar-08 3:42 
Questionselect statement that will retrieve all entries that have a certian letter combination in it? Pin
Mr Oizo19-Mar-08 4:40
Mr Oizo19-Mar-08 4:40 
AnswerRe: select statement that will retrieve all entries that have a certian letter combination in it? Pin
Dave Kreskowiak19-Mar-08 5:51
mveDave Kreskowiak19-Mar-08 5:51 
GeneralRe: select statement that will retrieve all entries that have a certian letter combination in it? Pin
Mr Oizo19-Mar-08 20:59
Mr Oizo19-Mar-08 20:59 
GeneralUnsigned Integers and Marshal.ReadInt32() Pin
VFaul19-Mar-08 4:16
VFaul19-Mar-08 4:16 
GeneralRe: Unsigned Integers and Marshal.ReadInt32() Pin
Dave Kreskowiak19-Mar-08 4:39
mveDave Kreskowiak19-Mar-08 4:39 
VFaul wrote:
Dim uiData as UInt32 = Marshal.ReadInt32(ipBuffer)

The exception only happens when the data has the most significant bit set (the "sign" bit). If Marshal.ReadUInt32() existed, obviously I would use that. Since it does not exist, I am marshaling the four bytes individually using Marshal.ReadByte() and constructing the unsigned integer. Is there a better way to do this?


No, not really. You're reading a four byte value as signed 32-bit integer (31 bits plus the sing bit), which means the number read can be a negative number, not positive. When the conversion to Unsigned is attempted, it can't convert a negative number, so you get the exception.

You can convert any number of bytes using the BitConverter class. You still need to read the four bytes into an array, but you can use the BitConverter.ToUInt32[^] method to do this, probably easier than you're doing it now.



A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007




GeneralRe: Unsigned Integers and Marshal.ReadInt32() Pin
VFaul19-Mar-08 7:25
VFaul19-Mar-08 7:25 
GeneralRe: Unsigned Integers and Marshal.ReadInt32() Pin
Dave Kreskowiak19-Mar-08 8:15
mveDave Kreskowiak19-Mar-08 8:15 
GeneralChanging VB Project Properties Pin
Jeeva Mary Varghese19-Mar-08 1:06
Jeeva Mary Varghese19-Mar-08 1:06 
QuestionHow to prevent multiple user login using one account in VB Pin
kingascona18-Mar-08 23:48
professionalkingascona18-Mar-08 23:48 
GeneralRe: How to prevent multiple user login using one account in VB Pin
Nilesh Hapse19-Mar-08 0:57
Nilesh Hapse19-Mar-08 0:57 
GeneralChange the title bar heading on a form in code... Pin
Mr Oizo18-Mar-08 22:45
Mr Oizo18-Mar-08 22:45 
AnswerRe: Change the title bar heading on a form in code... Pin
Rajesh Anuhya18-Mar-08 22:54
professionalRajesh Anuhya18-Mar-08 22:54 
GeneralRe: Change the title bar heading on a form in code... Pin
Mr Oizo19-Mar-08 0:34
Mr Oizo19-Mar-08 0:34 
GeneralProblem in opening a textfile in excel using vb.net Pin
Madang18-Mar-08 21:30
Madang18-Mar-08 21:30 
GeneralRe: Problem in opening a textfile in excel using vb.net Pin
Mycroft Holmes18-Mar-08 21:47
professionalMycroft Holmes18-Mar-08 21:47 
GeneralRe: Problem in opening a textfile in excel using vb.net [modified] Pin
Madang18-Mar-08 21:53
Madang18-Mar-08 21:53 
GeneralRe: Problem in opening a textfile in excel using vb.net Pin
Mycroft Holmes19-Mar-08 1:07
professionalMycroft Holmes19-Mar-08 1:07 
GeneralRe: Problem in opening a textfile in excel using vb.net Pin
Dave Kreskowiak19-Mar-08 4:28
mveDave Kreskowiak19-Mar-08 4:28 
Questionhow do I determine which button was clicked on a prevoius form to access the form I am currently working on? Pin
Mr Oizo18-Mar-08 21:18
Mr Oizo18-Mar-08 21:18 
AnswerRe: how do I determine which button was clicked on a prevoius form to access the form I am currently working on? Pin
Mycroft Holmes18-Mar-08 21:52
professionalMycroft Holmes18-Mar-08 21:52 
GeneralRe: how do I determine which button was clicked on a prevoius form to access the form I am currently working on? Pin
Mr Oizo18-Mar-08 22:41
Mr Oizo18-Mar-08 22:41 
AnswerRe: how do I determine which button was clicked on a prevoius form to access the form I am currently working on? Pin
Tom Wright19-Mar-08 8:58
Tom Wright19-Mar-08 8:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.