reading a binary file help

brodaddy2002

Board Regular
Joined
Jan 21, 2013
Messages
67
I have the following code below. I am trying to read DTED data into excel. I am not really sure what I am doing, but I think I am close. A couple of questions.

1) Can we use for input instead of Binary Access Read in the Open statement? I couldn't get for input to work.
2) Why do we not need a hash in front of intFileNum
3) What type variable is intFileNum?
4) Why isn't temp changing values? It when I try to do arithmetic?

Any help will be greatly appreciated


Code:
Public Sub reading3()
Dim intFileNum, bytTemp As Integer
Dim Letter As String
Dim i As Long
Dim j As Long
Dim test() As Integer
'Dim NewArray() As Integer
Dim x As Long
Dim temp As Integer




j = 1
intFileNum = FreeFile
Open "C:\Users\x\Documents\Thesis\Fallon DTED\rasexp_dted_1365124850_77725\dted\w114\n35.dt0" For Binary Access Read As intFileNum
'Seek intFileNum, 2
EData = filelen("C:\Users\x\Documents\Thesis\Fallon DTED\rasexp_dted_1365124850_77725\dted\w114\n35.dt0")
x = EData - 3428
ReDim NewArray(0 To EData) As Variant
For i = 3428 To EData
Seek intFileNum, i
Get intFileNum, , bytTemp
temp = bytTemp
If temp < 0 Then
    temp = -1 * ((temp + 32767) + 1)
End If


Debug.Print bytTemp


Range("A" & j) = bytTemp


j = j + 1
'    For j = 0 To (EData - 3428)
'        NewArray(j) = bytTemp
'    Next
'Letter = Chr(bytTemp)
Next
Debug.Print Letter
Close intFileNum
End Sub
 
Wow. That is some great stuff. I will have to look over how he did the colors. I also figured out the read in file after you had sent me the XVI32 read executable. Thanks again very much for your help. Excel can really do almost everything.
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
'He' did it with conditional formatting.

You're welcome.
 
Upvote 0
Did "he" do something to enlarge the area that is initial brought up? When I load the Bakersfield area data that you sent me, it only loads that DTED cell, but doesn't show the water red like the initial one that loaded. "he" probably had different dted information. Regardless, this macro will definitely get used in the near future. I can easily change the macro to display all the dted information within a designated folder. Thank you so much.;);)
 
Upvote 0

Forum statistics

Threads
1,215,421
Messages
6,124,806
Members
449,191
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top