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

please help me with this problem

kirubagari
158 100+
I want to check the arrangement of data in this order from byte 49 to mFile size(END OF FILE).
04 FF _ _ _ _ _04 FF _ _ _ _ 04 FF _ _.
_ __ 04 FF _ _ _ _ 04 FF _ _ _ _ 04 FF
Actually the values in the hex form. Each value represents 1 byte. Actually I already open the file in the binary editor using VB code. I would like to check the arrangement of data from byte 49 to MFileSize. If the code detect other than this 2 values ,I want to change it straight way to 04 FF.using the for loop i would like it check the data by i+5 it mean it go to 5th palce and check again until end of file.Someone please help me

This is my coding

Expand|Select|Wrap|Line Numbers
  1.  Private cmd check _click( )
  2.  Dim a as integer
  3.  Dim b as string
  4.  a=4
  5.  b=FF
  6.  
  7.   For i=49 to MfileSize
  8.    If
  9.        arrByte(i)<>a 
  10.             then a=4
  11.    end if
  12.    i=i+5
  13.    Next
  14.  
  15.  
  16.  
  17.  
  18. For i=50 to mFileSize
  19.      If arrByte(i) <> FF
  20. Then
  21.    b=FF
  22. Endif
  23.  i=i+5
  24. next
Jul 11 '07 #1
5 1270
Killer42
8,435 Expert 8TB
I think you need to study your basic programming concepts a bit more. In particular, the use of variables. Take this code...
Expand|Select|Wrap|Line Numbers
  1. If arrByte(i) <> a Then
  2.   a = 4
  3. End If
This code does absolutely nothing, because a is already equal to 4. a is not what you want to change.
Jul 11 '07 #2
Killer42
8,435 Expert 8TB
Try this one for size...

Expand|Select|Wrap|Line Numbers
  1. Private Sub check_click()
  2.   Const a As Byte = 4
  3.   Const b As Byte = &HFF
  4.   Dim i As Long
  5.  
  6.   For i = 49 To mFileSize Step 7
  7.     If arrByte(i) <> a Then
  8.       arrByte(i) = a
  9.     End If
  10.     If arrByte(i + 1) <> b Then
  11.       arrByte(i + 1) = b
  12.     End If
  13.   Next
  14. End Sub
Note, as far as I can see this is only changing the array arrByte, not the actual file. If you want this data back in the file, you will probably have to write it there afterward. (Unless there's some sort of link I'm not aware of between the array and the file.)
Jul 11 '07 #3
Killer42
8,435 Expert 8TB
I checked out your other posts, to get a better idea of what you're trying to do. This version should so what you want (I think) but I haven't tested it. One nice feature is that it will show you what it's doing, as it goes (just printing to the immediate window).

In any such situation, when changing data like this, I highly recommend keeping a backup copy of the input file, or writing the output to a different file. You should always be able to go back or start over if something goes wrong.

Expand|Select|Wrap|Line Numbers
  1. Private Sub check_click()
  2.   Const a As Byte = 4
  3.   Const b As Byte = &HFF
  4.   Dim i As Long
  5.   Dim AnyChanged As Boolean
  6.   Dim ChangeMade As Boolean
  7.  
  8.   For i = 49 To mFileSize Step 6
  9.     AnyChanged = False
  10.     Debug.Print "Before : "; Hex$(arrByte(i)); " "; Hex$(arrByte(i + 1)); " "; Hex$(arrByte(i + 2)); _
  11.     " "; Hex$(arrByte(i + 3)); " "; Hex$(arrByte(i + 3)); " "; Hex$(arrByte(i + 5))
  12.     If arrByte(i) <> a Then
  13.       arrByte(i) = a
  14.       ChangeMade = True
  15.     End If
  16.     If arrByte(i + 1) <> b Then
  17.       arrByte(i + 1) = b
  18.       ChangeMade = True
  19.     End If
  20.     If ChangeMade Then
  21.       AnyChanged = True
  22.       Debug.Print "After  : "; Hex$(arrByte(i)); " "; Hex$(arrByte(i + 1)); " "; Hex$(arrByte(i + 2)); _
  23.       " "; Hex$(arrByte(i + 3)); " "; Hex$(arrByte(i + 3)); " "; Hex$(arrByte(i + 5)); _
  24.       "  <--- Corrected"
  25.       Beep
  26.     End If
  27.     Debug.Print
  28.   Next
  29.  
  30.   ' At this point, variable AnyChanged tells you whether any
  31.   ' corrections were made, and thus whether you need to write
  32.   ' arrByte() back to the file.
  33.  
  34. End Sub
Jul 11 '07 #4
kirubagari
158 100+
Thank You Sir For Ur Help.im Not So Good In Programming But Ur Guide Realy Help Me Sir.thank You Very Much.thanks For Spent Ur Time To Guide Me Sir.
Jul 11 '07 #5
Killer42
8,435 Expert 8TB
By the way, you may find that the output looks a bit nasty because the hex values are sometimes one character, sometimes two. Just in case it's useful, here's an old function I wrote which will display the Hex value as a fixed number of characters. To use it, just plug it into any code module and then any time you want to print a byte value as two hex digits, just print HexByte2Char(value)

Expand|Select|Wrap|Line Numbers
  1. Public Function HexByte2Char(ByVal Value As Byte) As String
  2.   HexByte2Char = IIf(Value < &H10, "0", "") & Hex$(Value)
  3. End Function
Jul 11 '07 #6

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

Similar topics

6
by: Duane Lambe | last post by:
I'll start out by saying that I've been looking for a definitive answer for a few hours now, and need opinions on this one. I have a site I've been starting for our internal helpdesk joint....
0
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
2
by: Carlo, MCP | last post by:
Hi, Sorry for posting twice, but I hope in your comprehension. Please help me! I'm troubling from months with a serious serialization problem that I'm not able to solve. I try to describe as...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
by: funfair | last post by:
HI,EVERY ONE first problem, i have create a database in access 2003 it worked fine untill i have format my laptop . now im working on office 2003 on windows xp and i have norton 2006 but im...
1
by: oldgent | last post by:
I am having a problem installing the starter kits. I have reinstalled VS 2005, think that might be the problem. I then installed both 'Personal Website" and the "Club Website" starter kits. I...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
1
by: icetalks | last post by:
have a look at this code , its for logging the user in after checking his UserName and Password. dim check as boolean = false ... ... If txtUserName.Text.Length = 0 And txtPass.Text.Length =...
97
by: luap | last post by:
Hello good friends, please i need your help and advice on how i should best programme the problem, if possible a different option to solve it is welcomed. The problem a matching problem, how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.