Reading Double Precision Values From Binary File?

Feb 19, 2010

I am attempting to read a series of double prcision float values (x,y,z coordinates) from a binary file using the binary reader. Everything works fine except that when I read the number back it is different then the number that was written there (original file is generated by mining application).

written number : 78897.6476586
file contents hex : 40 F3 43 1A 5C CF 43 A4 this converts back to the same number as written using a IEE 754 conversion program. VB returned value : -5.45100266729248E-134 using .readDouble()

I have tried to step thru the file in one byte steps to make sure that I have the proper start position but that did not help any.

View 2 Replies


ADVERTISEMENT

Decimal And Double Precision

Jun 30, 2009

I am working on an application that allow the user to store data as numbers.These numbers are later on used for calculation. The number can be of any type and are saved as string. The problem is when they are used for calculation how can understand when it is better to treat them as doubles and when as decimals?

View 9 Replies

Change A Double To A Precision Of 2 Places To The Right Of Decimal Point?

Nov 22, 2009

how to get 1.83333333333... to 1.83?

Dim temp_1 As String
temp_1 = 5.50 / 3

Label1.Text = String.Format(temp_1, "{0.00}")

View 4 Replies

Read The Latitude And Longitude Byte Values From The DEM File (retrieving Binary Values)?

Mar 23, 2009

I have a DEM file(Digital Elevattion Model File) and I am trying to open the file,where we have Latitude and Longitude values inside the DEM file.And, Now I have opened the file using Filestream and Read the file using BinaryReader.But, I am having a trobule in getting the values of Latitude and Longitude.I am getting Byte values randomly as 1,202,31,271 etc.But, we dont have latitude and longitude values more than 180,and also I am not getting 16 bit UInt values.For example, the values should be like Latitude 20.00416666666667 and Longitude 39.99583333333333.So,read the correct Byte values of the DEM file.The code I have used till now is:

Dim fs As FileStream = New FileStream("C:UsersadminDesktopHeader and DEM fileE020N40.DEM", FileMode.Open, FileAccess.Read)
Dim rd As New BinaryReader(fs)
Dim convertDB As UInt16
For i = 0 To rd.BaseStream.Length

[code]....

View 14 Replies

File I/O And Registry :: Binary File Primer - Read The Nth Record Without Reading The Whole File?

May 4, 2009

I need to write data to a file, preferably in binary format, but I am unaccustomed with the concept. Where's the easiest place to get the basics? I could come here with a specific need, but I'm at the point right now where I am more willing to work within the confines of keeping it simple.

Here's what I know:
1. how to open a new file
2. how to specify the record length
3. how to close the file

Some specific questions:

Does the record length have to be constant throughout the file?

Can I read the nth record without reading the whole file?

View 8 Replies

Reading And Writing To A File In Binary?

Dec 20, 2010

few weeks ago i heard my teacher say that it is possible to view any file as a binary array (1s and 0s). if this is possible to do in visual basic please let me know how. Also how would i go about writing an array of binary to a file? For example 01100001 in a .txt file would produce "a"

View 4 Replies

Reading Strings From A Binary File?

Jul 30, 2010

I am fairly new to vb.net but was programming a long ime with vb6 I have a binary file that is a mixture of numbers (integers and doubles) and strings, such as "Programming with VB". I read the numbers using the BinaryStreamReader.ReadInt32 and BinaryStreamReader.ReadDouble, which are no problem

View 5 Replies

Reading Binary File As Text And Manipulating It

Sep 29, 2010

I am doing some exercises on encrypting data. One of them are binary files. I am currently using triple DES to encrypt and decrypt the files both in VB.NET and C#... Now the thing is, once it is decrypted in VB.NET and saved, I can execute it again... But for some reason, my C# file is bigger! 20,4K where VB.NET one is 19,0. The C# file also is rendered unexecutable...Upon a closer look. The files appear almost exactly the same, but C# seems to add in a few extra bytes here and there in (seemingly) random places... I am currently using:
File.ReadAllText(String filepath, Encoding encoding); with UTF-8 encoding.

View 1 Replies

VS 2008 HEX Editor - Reading Binary File?

Dec 1, 2010

Here is my code for reading a Binary file:
Dim fs As New FileStream(filepath, FileMode.Open)
Dim str As String = ""
For d As Integer = 0 To l - 1
Dim byt As String = Hex(fs.ReadByte()).ToUpper
fs.Position = d
str+= byt
Next

str becomes:
20202CB962AC5975B964B7152D234B
But when I open the file in a HEX editor, it's:
202CB962AC59075B964B07152D234B70
Why are the 2 different?

View 1 Replies

Reading A Text From A Binary File, Changing And Saving?

May 4, 2009

I'm new to VB and trying to figure out how I can replace a bit of descriptive text in a binary file. I presume its binary as I cant open it with anything but a hex editor. I've changed the text (file description) in the hex editor and saved it fine but I'm unsure how I go about saving just the section of information I need. I can work out the saving bit later.In the attached file you'll see the highlighted bit I want to edit. I need to replace the whole line or the file corrupt but I can fill it up with null characters and the numbers are just

View 3 Replies

Reading Binary File And Writing It To Some Table In Oracle

Jan 25, 2009

Reading binary file from hard drive in VB and writing to database.

View 3 Replies

FileGet Stops Reading Binary File At First Null (0) Byte?

Dec 18, 2011

I must search a binary string for a pattern. This worked fine in VB6 using Get to read a file into a string and using InStr to search for the pattern. The conversion from VB6 to VB.NET changed Get to FileGet and warned of new behavior, but I don't see anything in the FileGet documentation about not being able to read 0 value bytes.

I don't mind at all changing to a new method, but ultimately I must get the data into a string rather than an array.

[Code]...

View 2 Replies

VS 2005 Reading Comma Separated CSV File With Double Quote

Jan 26, 2010

I'm trying to read a csv file with comma separated. Problem is inside the file, it has one column which original value already contains Comma. Here is the example

[Code]....

So, when I Split the string with Comma, it gave me problem. Actually total it has 6 columns. But because of internal comma, it gave me 7 columns. And this CSV format can't change so I must deal with this problem. And so here I come out with a solution (because of its too long, I looking for better idea and solutions from you guys ):

[Code]....

View 2 Replies

Convert And Saving A Byte Array HEX Values To Binary File?

Jan 16, 2010

I have a device with upon serial communication , it send the data as HEX values , (eg, C020042ABD0F91A103E400F929EBC) . I use the following code to get data from the serial port.

Dim fStream As New FileStream(sFileName, FileMode.CreateNew) ' creates new file
Dim bw As New BinaryWriter(fStream)
System.Threading.Thread.Sleep(1500)
ComTd.Read(data, 1, bCount)

[code]....

View 8 Replies

Convert And Save Byte Array HEX Values To Binary File

Jun 5, 2011

I have a device with upon serial communication, it send the data as HEX values, (e.g., C020042ABD0F91A103E400F929EBC). I use the following code to get data from the serial port.

Dim fStream As New FileStream(sFileName, FileMode.CreateNew) ' creates new file
Dim bw As New BinaryWriter(fStream)
System.Threading.Thread.Sleep(1500)
ComTd.Read(data, 1, bCount)
Dim bCount As Integer = 4119 ' it is the size of the chunk not block size
Dim data(bCount) As Byte
[Code] .....

View 7 Replies

File I/O And Registry :: Binary Converter Reading String Letter By Letter

Sep 7, 2008

I have a binary converter I am attempting to build and want to read and convert the InputTextBox(alphabetical characters) letter by letter however all I have so far is one letter at a time

Image here is the code I have so far:

Code:
Public Class ConverterForm
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click

[Code]....

View 5 Replies

Reading Hex Values From A File?

Nov 7, 2010

I have a problem reading a file with hex values.

The values have this format: (2C 0A 0B 45 32 38)

I�ve tried two different ways to open the file. The first one, is storing in a variable of type string,

Dim srTrad As New System.IO.StreamReader(fichToOpen, System.Text.Encoding.ASCII, True)
sLine = srTrad.ReadLine()

so what I get is �2C0A0B453238�. Then I try to put them in pairs and reading as a HEX value, but I can�t. The only thing I get is the hex value of �2�, �C�, and so on. This is not what I�m looking for.

The second way is storing the values in a variable of type Byte:

Dim srByte As New IO.FileStream(fichToOpen, FileMode.Open, FileAccess.Read)
Dim br As New IO.BinaryReader(srByte)
Dim data As Byte() = br.ReadBytes(CInt(numBytes))

The result here, is pretty the same as before. For the pair �0A� what I get is either (30,41) or (48,65) (hex values or Dec). What I need isn�t to convert a char to its Hex value (I saw several examples for this on this forum). What I need is to know that 0A means 10 (0A is a hex value itself)

View 5 Replies

Reading Values From An Excel File?

Jan 22, 2010

I want to get a value from 12 excel sheet. is there any way that i get the values without opening the excel sheet? I am using vb.net. if there is a way to read values without opening the excel file.

View 3 Replies

Convert Binary Stream Into Double Array?

Aug 5, 2009

How to convert a binary stream (which is a string of numbers) into Double Array ? (VB.NET 2008)

View 3 Replies

Vb6 Double Versus .net Doubles In Binary Files?

Oct 1, 2011

I wrote some software in Vb6 a long while ago and this program creates a datafile. This datafile stores variables like doubles, ints, arrays etc, using the Get/Put methods from VB6. This all worked great for vb6.I am now starting to rewrite this tool in .net and find that the binaryreader as well as the other fileopen methods do not convert the doubles correctly. So as I rewrite the software I still want to read the old datafiles just like before.if I use a byte array and read 8 bytes, the bytes read are identical in Vb6 and vb.net. We are talking about reading an existing old binary file created by vb6.

for example the number 3, stored as a double has a 8 byte array that looks like this:

[0][0][0][0][0][0][0][5] in vb6.

in vb.net if you use the bitconverter.getbytes(cdbl(3)) you get

[0][0][0][0][0][0][8]64]

in vb6 the first array is converted to the # 3 correctly.in vb.net the array is converted to something way way off.

View 22 Replies

.net - NULL Values Reading From Excel File?

Mar 4, 2010

i am not getting the integer values in dataset while reading from an excel files the field which is integer will be showing as NULL.

View 1 Replies

Reading Values In Cells From Excel .csv File?

Sep 6, 2011

I am new to VB.NET and I am trying to read a line of data from a .csv file. For some reason the line of code below is returning "System.__ComObject", why? I verified that the cell contains "4/8/2011 9:20".

Me.cv_wks.Cells(i, "G").ToString

View 2 Replies

VS 2010 - Reading Text File And Returning Values To Textbox

Apr 17, 2011

I've a got a homework assignment that chooses one of four values in a list box, stores it in a text file. Secondly, on the display click event it should access the text file, read the line, store it in a variable and then display the totals in a text box. Works sort of fine except that it doesn't display the totals correctly. Code for both buttons is below. The variable are assigned in the mainform (Tried also in the display button and didn't change anything). The save button works fine and stores fine in the text file, it's just the reading that's the problem.

Private Sub saveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveButton.Click
'save the new vote choices to a file
Dim votes As IO.StreamWriter
votes = IO.File.AppendText("votes.txt")
Dim voteSelected As String = CStr(commercialListBox.SelectedIndex)
[Code] .....

View 2 Replies

VS 2008 - Read A 16bit Binary File (tif Image) And Pixel Values Of The Image Ranges From 1200 To 4500 - EndOfStreamException Unhandled Error

Mar 18, 2012

I am trying to read a 16bit binary file (tif image) and pixel values of the image ranges from 1200 to 4500. I tried to use BinaryReader using ReadUInt16 but I get EndOfStreamException Unhandled error. ReadByte method works fine with an 8bit tif file. I do not know how to read a 16bit image file using binaryReader. Shouldn't I use ReadUInt16 since values of pixels range from 1200 to 4500?

[Code]....

View 10 Replies

Reading Binary Data From Sql Server

Sep 22, 2010

i am trying to read data from a sql 2000 database.one of the fields is defined as datatype:image, Length:16.when I am in SQL management studio and do a select for this one column.[code]when i do a datalength on this field it come up with 2404/My question is, I know this is a numeric field, how do i read this into a vb app and how do I break this down into individual values?

View 2 Replies

SyncLock / Multithreading - Child Thread Reading The Values Of _do At The Same Time As Another Child Thread Is Reading The Values

Nov 13, 2009

I have a dictionary object (let's call it _do) I am using to cache some values for use in a multi-threaded program. I have a single controlling parent thread, with a timer function _doTimer() which can kick off child threads with a new instance of class MyThreadObject in each. My parent thread has _do as a property and with each time _doTimer() gets called, it may or may not repopulate _do depending on cacheflag settings. I pass a reference to _do to each instance of MyThreadObject and those threads at some point read the values of _do but DO NOT write to it.

What I want is to ensure that the child threads do not try and read _do whilst the parent thread is writing to it. Same thing but very slightly different -> I also don't want the parent thread to write to _do whilst the child threads are reading from it. However there is no problem with 1 child thread reading the values of _do at the same time as another child thread is reading the values - so ideally I do not want each child thread to completely lock out read access, only locking out Write access.. The code is roughly like this:

[Code]....

View 3 Replies

Iphone - Correct Format For Reading And Writing Binary Strings Using Ifstream

Feb 1, 2011

I'm trying to read back a string that I wrote into a binary file, but it's giving me problems and I don't know what's going on. I open and read my file using the code below:

ifstream input([filePath UTF8String], ios::in | ios::binary);
int numStringBytes;
input.read((char*)&numStringBytes, 4);

[Code]....

View 1 Replies

Iphone - Correct Format For Reading And Writing Binary Strings Using Ifstream?

Sep 24, 2010

I'm trying to read back a string that I wrote into a binary file, but it's giving me problems and I don't know what's going on. I open and read my file using the code below:

ifstream input([filePath UTF8String], ios::in | ios::binary);
int numStringBytes;
input.read((char*)&numStringBytes, 4);

[code]....

There is a lot more to the file reading code, but it's proprietary and this is the part that keeps crashing. It runs fine loading the first two files, but when I try to open a third file, it crashes with EXC_BAD_ACCESS at the input.read((char*)names, numStringBytes); line. I don't see any reason that this should crash. I'm writing the binary files in VB.NET using the below code:

Dim myFS As New FileStream(savePath, FileMode.Create)
Dim encoding As New System.Text.UTF8Encoding()
Dim stringBytes() As Byte = encoding.GetBytes("++string")

[code]....

View 5 Replies

MouseButtons - Binary Values For Each Button

Apr 29, 2009

MSDN states that the return value of System.Windows.Forms.SystemInformation.MouseButtons is INTEGER. I expected that, but I also expected that they would talk about the binary values for each button. My mouse has a mouse wheel, so technically I have 4 "buttons". The return value I get is "16". But this doesn't add up (at least the way it used to add up in vb6) so I wish MSDN took it that necessary extra step to clarify the logic behind the returned values for .NET. For instance, if I add up mouse button values based on binary assignments:

CODE:

So for a 3-button mouse + wheel, why is the return value for .MouseButtons, "16"?

If it's a hex value, that is more problematic.

View 5 Replies

Setting Registry Values With Binary Value Kind?

Sep 14, 2010

I am a newbie so please forgive me if my terminology is incorrect.I am trying to Update a Registry sub key value. I have done this a few times before with success. But this time is kinda different. I noticed a few things,like the sub key value is in HEX when I export the key (The value that I want to input is from a sub key that I exported) I can only get the registry to accept the command if I do not specify the registry value kind, but that doesn't do me any good if its not the correct value kind.

[Code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved