473,224 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Could this be a bug in VB.NET ??

In VS.NET 2003 (VB.NET):
Microsoft Development Environment 2003 Version 7.1.3088
Microsoft .NET Framework 1.1 Version 1.1.4322 SP1

Here's a small piece of code which works fine:

Private Sub Button3_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles Button3.Click
' Convert a Decimal to an Int32 Array
' and then back to a Decimal
Dim dec1 As Decimal
Dim dec2 As Decimal
dec1 = Decimal.Parse(TextBox1.Text)
Dim i32A As Int32()
Dim i32B(4) As Int32
i32A = Decimal.GetBits(dec1)
Debug.Write(i32A(0).ToString & vbCrLf)
Debug.Write(i32A(1).ToString & vbCrLf)
Debug.Write(i32A(2).ToString & vbCrLf)
Debug.Write(i32A(3).ToString & vbCrLf)
i32B = i32A
Debug.Write(i32B(0).ToString & vbCrLf)
Debug.Write(i32B(1).ToString & vbCrLf)
Debug.Write(i32B(2).ToString & vbCrLf)
Debug.Write(i32B(3).ToString & vbCrLf)
dec2 = New Decimal(i32B)
TextBox3.Text = dec2.ToString()
End Sub
-----
Input: 43683683.368268265
-----
Debug: 497381865
10170900
0
589824
497381865
10170900
0
589824
-----
Output: 43683683.368268265
-----

And here's a similar piece which bombs and I can't figure
out why:

Private Sub Button3_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles Button3.Click
' Convert a Decimal to an Int32 Array
' then to an array of (unsigned) bytes
' then back to an Int32 Array
' and then back to a Decimal
Dim dec1 As Decimal
Dim dec2 As Decimal
dec1 = Decimal.Parse(TextBox1.Text)
Dim i32A As Int32()
Dim i32B(4) As Int32
i32A = Decimal.GetBits(dec1)
Debug.Write(i32A(0).ToString & vbCrLf)
Debug.Write(i32A(1).ToString & vbCrLf)
Debug.Write(i32A(2).ToString & vbCrLf)
Debug.Write(i32A(3).ToString & vbCrLf)
Dim BA As Byte()
Dim BB As Byte()
Dim BC As Byte()
Dim BD As Byte()
BA = BitConverter.GetBytes(i32A(0))
BB = BitConverter.GetBytes(i32A(1))
BC = BitConverter.GetBytes(i32A(2))
BD = BitConverter.GetBytes(i32A(3))
i32B(0) = BitConverter.ToInt32(BA, 0)
i32B(1) = BitConverter.ToInt32(BB, 0)
i32B(2) = BitConverter.ToInt32(BC, 0)
i32B(3) = BitConverter.ToInt32(BD, 0)
Debug.Write(i32B(0).ToString & vbCrLf)
Debug.Write(i32B(1).ToString & vbCrLf)
Debug.Write(i32B(2).ToString & vbCrLf)
Debug.Write(i32B(3).ToString & vbCrLf)
dec2 = New Decimal(i32B) <-- Error is Here **
TextBox3.Text = dec2.ToString()
End Sub
-----
Input: 43683683.368268265
-----
Debug: 497381865
10170900
0
589824
497381865
10170900
0
589824
-----
Output: An unhandled exception of type
'System.ArgumentException' occurred
in mscorlib.dll

Additional information: Decimal byte
array constructor requires an array
of length four containing valid
decimal bytes.
-----

But note that the Debug lines still show the Int32
arrays are identical. Any ideas?

Jul 29 '05 #1
0 1095

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

Similar topics

1
by: Matthias Ludwig | last post by:
I'm trying to create a directory on the web server with a vb.net code: .... Dim dirName As String = "w:\filepath\images" If Not Directory.Exists(dirName) Then...
1
by: Afaq | last post by:
Hi, After adding large number of empty resource files (which will be updated later), we are not able to compile the project. the following is the output of the build process. It fails while...
20
by: ctyrrell | last post by:
Does anyone have any idea how to recover from a run-time error 3002 which I get after creating a workspace 242 times? Or better yet, avoid getting it in the first place? I am creating a...
2
by: Kevin R. | last post by:
I have been ignoring this problem for a few weeks now, but it's becoming a bit annoying not to mention unproductive. Here it goes: I compile my project with no errors. Then after I debug/run it,...
2
by: ruben20 | last post by:
Hi: I've migrated a couple of weeks ago from 7.4.2 to 7.4.5 and I am getting this error after executing a query: Warning: pg_exec() query failed: ERROR: could not access status of transaction...
0
by: Derek | last post by:
I am creating an intranet using Visual Web Developer Express Edition. Everything has been working OK until yesterday when I started getting 62 messages all beginning "Could not find schema...
0
by: jhansen | last post by:
I am getting informational warnings about the following app.config and indicate the following. I am using C# visual studio 2005 and used the Settings.settings to set up my values scoped as...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
1
by: vineetbindal | last post by:
Hi All, I am new to silverlight and i am following a tutorial. In order to connect to database in silverlight application i need to add a referance to a service. which gives me an error that the...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.