![]() |
Reading binary file
http://www.justlottery.com/dwnld/INDSuperlotto.rtl
http://www.justlottery.com/dwnld/INDThunderball.rtl http://www.justlottery.com/dwnld/INDFast.rtl Can anybody help reading the above three binary file in excel through a vba? The following macro reads the first file but not through Excel VBA, it reads to Visual Basic. Can anybody understand the logic of the below code and convert into Excel macro? Option Explicit Private Type TREC No As Integer D As Integer M As Integer Y As Integer Numbers(1 To 10) As Integer End Type Private Sub Command1_Click() Const Fle$ = "c:\t\t.rtl" Dim B(1 To 28) As Byte Dim Channel%, L9&, L8&, Max& Dim Rec As TREC Me.Cls Channel = FreeFile Open Fle For Binary Access Read As Channel ' Get 4 byte header - No of lines Get #Channel, 1, Max& Me.Print Max ' --- Now the 28 byte records For L9 = 1 To 10 Get #Channel, , Rec Disp Rec.No Disp Rec.D Disp Rec.M Me.CurrentX = Me.CurrentX + TextWidth("XX") Disp Rec.Y For L8 = 1 To 10 Disp Rec.Numbers(L8) Next Me.Print "" Next Close #Channel End Sub Private Sub Disp(N%) Dim S$ S$ = Trim$(N) Me.CurrentX = Me.CurrentX + TextWidth("XXX") _ - TextWidth(S$) Me.Print S$; End Sub Private Sub Form_Load() Me.AutoRedraw = True Me.Width = Screen.Width * 0.75 End Sub |
Reading binary file
This worked for me
Tim '------------------------------------------------ Private Type TREC No As Integer D As Integer M As Integer Y As Integer Numbers(1 To 10) As Integer End Type Private Sub Tester() Const Fle$ = "U:\desktop\templotto.rtl" Dim B(1 To 28) As Byte Dim Channel%, L9&, L8&, Max& Dim Rec As TREC Channel = FreeFile Open Fle For Binary Access Read As Channel ' Get 4 byte header - No of lines Get #Channel, 1, Max& Debug.Print Max ' --- Now the 28 byte records For L9 = 1 To 10 Get #Channel, , Rec Disp Rec Debug.Print "" Next Close #Channel End Sub Private Sub Disp(Rec As TREC) Dim L8 As Integer Debug.Print "----Record------------" Debug.Print "No: " & Rec.No Debug.Print "D: " & Rec.D Debug.Print "M: " & Rec.M Debug.Print "Y: " & Rec.Y For L8 = 1 To 10 Debug.Print "Num " & L8 & ": " & _ Trim(Rec.Numbers(L8)) Next End Sub '----------------------------------------------------------------- -- Tim Williams Palo Alto, CA "Maxi" wrote in message oups.com... http://www.justlottery.com/dwnld/INDSuperlotto.rtl http://www.justlottery.com/dwnld/INDThunderball.rtl http://www.justlottery.com/dwnld/INDFast.rtl Can anybody help reading the above three binary file in excel through a vba? The following macro reads the first file but not through Excel VBA, it reads to Visual Basic. Can anybody understand the logic of the below code and convert into Excel macro? Option Explicit Private Type TREC No As Integer D As Integer M As Integer Y As Integer Numbers(1 To 10) As Integer End Type Private Sub Command1_Click() Const Fle$ = "c:\t\t.rtl" Dim B(1 To 28) As Byte Dim Channel%, L9&, L8&, Max& Dim Rec As TREC Me.Cls Channel = FreeFile Open Fle For Binary Access Read As Channel ' Get 4 byte header - No of lines Get #Channel, 1, Max& Me.Print Max ' --- Now the 28 byte records For L9 = 1 To 10 Get #Channel, , Rec Disp Rec.No Disp Rec.D Disp Rec.M Me.CurrentX = Me.CurrentX + TextWidth("XX") Disp Rec.Y For L8 = 1 To 10 Disp Rec.Numbers(L8) Next Me.Print "" Next Close #Channel End Sub Private Sub Disp(N%) Dim S$ S$ = Trim$(N) Me.CurrentX = Me.CurrentX + TextWidth("XXX") _ - TextWidth(S$) Me.Print S$; End Sub Private Sub Form_Load() Me.AutoRedraw = True Me.Width = Screen.Width * 0.75 End Sub |
Reading binary file
Information stored in these .rtl files are like these:
For INDSuperlotto.rtl : 00001 28 03 2002: 14 21 22 29 39 43 00002 04 04 2002: 07 24 27 28 29 47 For INDThunderball.rtl : 00001 07 09 2004: 12 16 21 30 31 TB 03 00002 14 09 2004: 17 18 30 39 42 TB 04 For INDFast.rtl : 00001 01 09 2004: 05 06 10 13 30 00002 02 09 2004: 07 08 23 24 31 I have included first and second records in each files. There are too many that I want to decode Instead of Debug.Print, can I get the output in excel cells in the above format? Tim Williams wrote: This worked for me Tim '------------------------------------------------ Private Type TREC No As Integer D As Integer M As Integer Y As Integer Numbers(1 To 10) As Integer End Type Private Sub Tester() Const Fle$ = "U:\desktop\templotto.rtl" Dim B(1 To 28) As Byte Dim Channel%, L9&, L8&, Max& Dim Rec As TREC Channel = FreeFile Open Fle For Binary Access Read As Channel ' Get 4 byte header - No of lines Get #Channel, 1, Max& Debug.Print Max ' --- Now the 28 byte records For L9 = 1 To 10 Get #Channel, , Rec Disp Rec Debug.Print "" Next Close #Channel End Sub Private Sub Disp(Rec As TREC) Dim L8 As Integer Debug.Print "----Record------------" Debug.Print "No: " & Rec.No Debug.Print "D: " & Rec.D Debug.Print "M: " & Rec.M Debug.Print "Y: " & Rec.Y For L8 = 1 To 10 Debug.Print "Num " & L8 & ": " & _ Trim(Rec.Numbers(L8)) Next End Sub '----------------------------------------------------------------- -- Tim Williams Palo Alto, CA "Maxi" wrote in message oups.com... http://www.justlottery.com/dwnld/INDSuperlotto.rtl http://www.justlottery.com/dwnld/INDThunderball.rtl http://www.justlottery.com/dwnld/INDFast.rtl Can anybody help reading the above three binary file in excel through a vba? The following macro reads the first file but not through Excel VBA, it reads to Visual Basic. Can anybody understand the logic of the below code and convert into Excel macro? Option Explicit Private Type TREC No As Integer D As Integer M As Integer Y As Integer Numbers(1 To 10) As Integer End Type Private Sub Command1_Click() Const Fle$ = "c:\t\t.rtl" Dim B(1 To 28) As Byte Dim Channel%, L9&, L8&, Max& Dim Rec As TREC Me.Cls Channel = FreeFile Open Fle For Binary Access Read As Channel ' Get 4 byte header - No of lines Get #Channel, 1, Max& Me.Print Max ' --- Now the 28 byte records For L9 = 1 To 10 Get #Channel, , Rec Disp Rec.No Disp Rec.D Disp Rec.M Me.CurrentX = Me.CurrentX + TextWidth("XX") Disp Rec.Y For L8 = 1 To 10 Disp Rec.Numbers(L8) Next Me.Print "" Next Close #Channel End Sub Private Sub Disp(N%) Dim S$ S$ = Trim$(N) Me.CurrentX = Me.CurrentX + TextWidth("XXX") _ - TextWidth(S$) Me.Print S$; End Sub Private Sub Form_Load() Me.AutoRedraw = True Me.Width = Screen.Width * 0.75 End Sub |
Reading binary file
What I posted should be enough get you started.
If you have *no* VB or VBA knowledge and are looking for someone to provide a full solution, then you might be better off just paying $25 for the sofware... Tim -- Tim Williams Palo Alto, CA "Maxi" wrote in message oups.com... Information stored in these .rtl files are like these: For INDSuperlotto.rtl : 00001 28 03 2002: 14 21 22 29 39 43 00002 04 04 2002: 07 24 27 28 29 47 For INDThunderball.rtl : 00001 07 09 2004: 12 16 21 30 31 TB 03 00002 14 09 2004: 17 18 30 39 42 TB 04 For INDFast.rtl : 00001 01 09 2004: 05 06 10 13 30 00002 02 09 2004: 07 08 23 24 31 I have included first and second records in each files. There are too many that I want to decode Instead of Debug.Print, can I get the output in excel cells in the above format? Tim Williams wrote: This worked for me Tim '------------------------------------------------ Private Type TREC No As Integer D As Integer M As Integer Y As Integer Numbers(1 To 10) As Integer End Type Private Sub Tester() Const Fle$ = "U:\desktop\templotto.rtl" Dim B(1 To 28) As Byte Dim Channel%, L9&, L8&, Max& Dim Rec As TREC Channel = FreeFile Open Fle For Binary Access Read As Channel ' Get 4 byte header - No of lines Get #Channel, 1, Max& Debug.Print Max ' --- Now the 28 byte records For L9 = 1 To 10 Get #Channel, , Rec Disp Rec Debug.Print "" Next Close #Channel End Sub Private Sub Disp(Rec As TREC) Dim L8 As Integer Debug.Print "----Record------------" Debug.Print "No: " & Rec.No Debug.Print "D: " & Rec.D Debug.Print "M: " & Rec.M Debug.Print "Y: " & Rec.Y For L8 = 1 To 10 Debug.Print "Num " & L8 & ": " & _ Trim(Rec.Numbers(L8)) Next End Sub '----------------------------------------------------------------- -- Tim Williams Palo Alto, CA "Maxi" wrote in message oups.com... http://www.justlottery.com/dwnld/INDSuperlotto.rtl http://www.justlottery.com/dwnld/INDThunderball.rtl http://www.justlottery.com/dwnld/INDFast.rtl Can anybody help reading the above three binary file in excel through a vba? The following macro reads the first file but not through Excel VBA, it reads to Visual Basic. Can anybody understand the logic of the below code and convert into Excel macro? Option Explicit Private Type TREC No As Integer D As Integer M As Integer Y As Integer Numbers(1 To 10) As Integer End Type Private Sub Command1_Click() Const Fle$ = "c:\t\t.rtl" Dim B(1 To 28) As Byte Dim Channel%, L9&, L8&, Max& Dim Rec As TREC Me.Cls Channel = FreeFile Open Fle For Binary Access Read As Channel ' Get 4 byte header - No of lines Get #Channel, 1, Max& Me.Print Max ' --- Now the 28 byte records For L9 = 1 To 10 Get #Channel, , Rec Disp Rec.No Disp Rec.D Disp Rec.M Me.CurrentX = Me.CurrentX + TextWidth("XX") Disp Rec.Y For L8 = 1 To 10 Disp Rec.Numbers(L8) Next Me.Print "" Next Close #Channel End Sub Private Sub Disp(N%) Dim S$ S$ = Trim$(N) Me.CurrentX = Me.CurrentX + TextWidth("XXX") _ - TextWidth(S$) Me.Print S$; End Sub Private Sub Form_Load() Me.AutoRedraw = True Me.Width = Screen.Width * 0.75 End Sub |
All times are GMT +1. The time now is 05:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com