473,396 Members | 2,018 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,396 software developers and data experts.

reading data until eof

kirubagari
158 100+
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdscan_Click()
  2.  
  3.   Const a As Byte = 4
  4.   Const b As Byte = &HFF
  5.   Dim I As Long
  6.   Dim AnyChanged As Boolean
  7.   Dim changeMade As Boolean
  8.   Dim value As Byte
  9.   'Dim x
  10.   'Dim tmp As String
  11.  
  12.   For I = 1 To 100 Step 6
  13.     AnyChanged = False
  14.     Debug.Print "Before : "; HexByte2Char(arrByte(I)); " "; HexByte2Char(arrByte(I + 1)); " "; HexByte2Char(arrByte(I + 2)); _
  15.     " "; HexByte2Char(arrByte(I + 3)); " "; HexByte2Char(arrByte(I + 4)); " "; HexByte2Char(arrByte(I + 5))
  16.    ' Print HexByte2Char(I)
  17.  
  18.     If arrByte(I) <> a Then
  19.       arrByte(I) = a
  20.       value = a
  21.       changeMade = True
  22.  
  23.     End If
  24.     If arrByte(I + 1) <> b Then
  25.       arrByte(I + 1) = b
  26.       changeMade = True
  27.     End If
  28.     If changeMade Then
  29.       AnyChanged = True
  30.       Debug.Print "After  : "; HexByte2Char(arrByte(I)); " "; HexByte2Char(arrByte(I + 1)); " "; HexByte2Char(arrByte(I + 2)); _
  31.       " "; HexByte2Char(arrByte(I + 3)); " "; HexByte2Char(arrByte(I + 4)); " "; HexByte2Char(arrByte(I + 5)); _
  32.       "  <--- Corrected"
  33.     End If
  34.     Debug.Print
  35.   Next
  36.  
  37. End Sub

this is the way i open the file


Expand|Select|Wrap|Line Numbers
  1. Open "a:\bonding.bin " For Binary As mHandle
  2.     'Open gcdg.FileName For Binary As #mHandle
  3.     mFileSize = LOF(mHandle)
  4.     If mFileSize = 0 Then
  5.          Close mHandle
  6.          MsgBox "Empty file"
  7.          Exit Sub
  8.     End If
  9.     Screen.MousePointer = vbCross
  10.  
  11.     ReDim arrByte(1 To mFileSize)
  12.     Get #mHandle, , arrByte
  13.     Close mHandle
  14.  
  15.  
  16.     rtbChr.Text = ""
  17.     rtbChr.LoadFile gcdg.FileName


actualy just know u mention to me that ask me to figure out where the problem occur.When i try to loop from byte 1 to 100 it can loop and give the output.When i try to put 1 to mfilesize it cant loop and it stuck.I do no why its happening.The mFilesize is the end of file.When i try to open the file in the binary editor that i did it can read until end of file.im asking why it cant read until end of file.
Jul 13 '07 #1
4 1503
Killer42
8,435 Expert 8TB
Where is the variable mFileSize defined?
Jul 13 '07 #2
kirubagari
158 100+
the variable used is Dim mfilesize as long
Jul 13 '07 #3
Killer42
8,435 Expert 8TB
the variable used is Dim mfilesize as long
What I asked is where it's defined. The scope of the variable is important. Also, do you have Option Explicit at the start of each module and form? This can prevent a lot of problems.
Jul 13 '07 #4
Killer42
8,435 Expert 8TB
actualy just know u mention to me that ask me to figure out where the problem occur.When i try to loop from byte 1 to 100 it can loop and give the output.When i try to put 1 to mfilesize it cant loop and it stuck.I do no why its happening.The mFilesize is the end of file.When i try to open the file in the binary editor that i did it can read until end of file.im asking why it cant read until end of file.
One more thing. I think the next step in debugging this would be to place a break point on the For statement (put the text cursor on it and press F9 - the line will be highlighted, probably in red).

When you run it, it will stop at that line and you can check what the value is in your variable. It's always a good idea to make sure you really are working with the values you think you are.
Jul 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
3
by: Adman | last post by:
Hi all. I've done some websearching, and haven't been able to find my question answered, so I thought I'd post. I apologize if this has already been answered. My question seems to be a...
3
by: Alex Clark | last post by:
Hi All, I'm having some problems reading a network stream. I'm writing a lightweight POP client to handle a very specific task, but I keep unexpectedly reaching the end of the datastream when...
5
by: Dave A | last post by:
I have an application that does lots of socket communications all asynchronously via the TcpClient class. The code has been working 99.9999% of the time (yeah one of those bugs) but occasionally...
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
7
by: jccorreu | last post by:
I've got to read info from multiple files that will be given to me. I know the format and what the data is. The thing is each time we run the program we may be using a differnt number of files,...
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
3
by: Willy Stevens | last post by:
Hello, In my application I have to read sometimes quite big chunk of binary data. I have a buffer which default size is 32000 bytes. But how could I read binary data that exceeds 32000 bytes?...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
5
by: Luis Zarrabeitia | last post by:
I have a problem with this piece of code: ==== import sys for line in sys.stdin: print "You said!", line ==== Namely, it seems that the stdin buffers the input, so there is no reply until ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.