Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

How can ascii 2, 11, 16, 17, 18, 19 be in my text file

I am getting run time error

After investigation I discovered that ascii 2, 11, 16, 17, 18, 19 are in my text file.

For example 1 year ago I saved the following string 3AD3, which is 4 characters length then I discovered that ascii 18 came between A and D so it became 5 characters length.

Of course char 18 can not be seen so it took me long to find out.

How did it get there?

Note that the 3AD3 is not keyed in, it is generated during saving.
e.g. I order my prog to save the number 15059 then it saves it's hex 3AD3

I am suspecting a defect hard drive, a virus, or what?
0
saljas
Asked:
saljas
  • 7
  • 6
  • 3
  • +1
1 Solution
 
TommySzalapskiCommented:
Inserting control characters between the bytes of a number that you are saving is very odd behavior indeed. I don't know of any viruses that would do that and I'm not really sure that hard drive errors would do that. Usually corruption from a bad disk or virus will change a byte, but not insert one.

If you think about it, to "insert" a byte on a disk, you would need to shift (copy) everything else over to open up the space for the bad byte.

My guess would be that the program that converts the number to hex and saves it has some issues. I would check that first.
0
 
aikimarkCommented:
hex(15059)=3AD3

I suspect you are saving the data in non-textual format and reading it in a hex file viewer.
0
 
aikimarkCommented:
What does your file output code look like?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
saljasAuthor Commented:
After rechecking similor files I discovered that 3AD3 is not the original number.
The original number was 3A?D3
So, the third char is unknown changed to me, which is replaced by ascii 18.

Also, when I post I was checking a field in the record.  So, after checking the whole record I discovered that many characters were replaced by ascii ( 2, 11, 16, 17, 18, 19 ).

(How do I know it is replaced)
becoming
(Hw do I kno it s relaced)

The following is the code and it is written many years ago

V=12345
Dim Rec As string
Open "Myfile.txt" for output as #1
Rec = "My text" & Hex(V)
print #1, rec
close #1

may be it is beter to replace the harddisk,  or is it a virus
0
 
aikimarkCommented:
what are you using to see the inserted byte?
0
 
saljasAuthor Commented:
By this I can tell were is the bad ascii and in which field

For I=1 to Len(mytext)
      AscIs = asc(Mid(MyText,I,1))
      If AscIs < 32    then      List1.additem I & ":>" & AscIs
next
0
 
aikimarkCommented:
please post the code that reads the file as well
0
 
saljasAuthor Commented:
I am expecting answers like:-

1- Yes there is a virus called ...... it behavior is adding Lower ascii

or

2- Yes the broken hard disk behavior is adding Lower ascii

Or????
0
 
saljasAuthor Commented:
dim rec as string
open "MyFile.txt" for input as #1
Do while not eof(1)
  Line input #1, rec
  For I=1 to Len(rec)
      AscIs = asc ( Mid (rec ,I ,1 ))
      If AscIs < 32    then      List1.additem I & ":>" & AscIs
  next
loop
close #1
0
 
aikimarkCommented:
I'm assuming that you have run some AV programs (AVG and Malwarebytes) against your hard drive and found no infections.  Have you looked for a rootkit infection?

The next step is to use a different media.  Insert a thumb drive and do your write/read test to the thumb drive.  If the problem is seen in this test, then we can rule our a problem with the hard drive.

Do me a favor and add an Option Explicit statement to your General Declarations section.  This will force you to declare all your variables.
0
 
TommySzalapskiCommented:
1- Yes there is a virus called ...... it behavior is adding Lower ascii
2- Yes the broken hard disk behavior is adding Lower ascii

But remember, inserting bytes in the middle of other bytes is not something that disk errors can do because it would need to shift everything. Viruses don't do that either. It's just a lot harder than other ways to mess things up.

If you saw 3A D3 37 turn into 3A 18 37, then it would make sense to be a disk error.

What you are seeing must be happening when the data is being written or when it is being read. That's why we are asking to see how that happens.


The original number was 3A?D3
Ah. Now that makes some sense. That's not the ASCII '?' character. That's how it is choosing to display non-printable characters. I'll bet anything below 32 is displayed as a ?. What are you opening it in to see the question mark?
0
 
saljasAuthor Commented:
TommySzalapski,
 in the first post I wrote
Of course char 18 can not be seen so it took me long to find out.
So I am adding "?" for explanation

aikimark
The file contains 56000 records, the prog is working since 2001
The problem happened in 20 records above 55100
If it is Explicit problem then it would appear in the last 12 years with 55000 records.
Also it is not a steady problem that happens for every record, so I might test on a new media without getting a firm answer.

And,
Since this is a customer's computer then I'll investigate the RootKit or any other infections.

I thought that there is a virus or malware or .... that causes char replacement

Many thanks for both of you
0
 
TommySzalapskiCommented:
Oh, I just realized what you meant.
" I discovered that 3AD3 is not the original number. The original number was 3A?D3
So, the [middle] char is unknown changed to me, which is replaced by ascii 18."

So the middle byte there got changed from whatever it was to 18.

Now that makes sense and sounds like any number of possible disk errors or viruses.

Certainly run virus scans on the computer if you haven't already and disk checks too. Either run chkdsk or if you prefer user friendly things, follow these instructions
http://windows.microsoft.com/en-us/windows-vista/check-your-hard-disk-for-errors
(right click on C:\, click 'properties', click 'tools' tab, click 'Check now...' under 'Error checking')
0
 
saljasAuthor Commented:
many thanks for every body
Please close my question
0
 
saljasAuthor Commented:
how to close without accepting
0
 
aikimarkCommented:
how to close without accepting
Is your problem solved?  If so, what comment states the solution?  

If you solved the problem yourself, then accept your comment that describes the solution.
0
 
Martin LissRetired ProgrammerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 7
  • 6
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now