I loop a txt file with the tipical
free file...#1 ecc....
in the string are hex cahrcter 00 (see image).
Is possible to intecept in the string and replace with space chr?
tks.
SUBSTITUTE hex chr with other ...
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
SUBSTITUTE hex chr with other ...
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SUBSTITUITE hex chr with other ...
Say you have a variable MyString that you use to read data from the file. You can then use
MyString = Replace(MyString, Chr(0), " ")
MyString = Replace(MyString, Chr(0), " ")
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: SUBSTITUITE hex chr with other ...
hummmm...HansV wrote:Say you have a variable MyString that you use to read data from the file. You can then use
MyString = Replace(MyString, Chr(0), " ")
the image is refered to a Hex editor, not is the line in question
in my case 20 is a space and the . is 00 all both character in Hex
Last edited by sal21 on 13 Dec 2011, 15:50, edited 1 time in total.
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: SUBSTITUITE hex chr with other ...
for test i use a Hex editor....HansV wrote:How do you read the line?
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SUBSTITUITE hex chr with other ...
Yes, I understand, but how do you read the line in VBA?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: SUBSTITUITE hex chr with other ...
sorry me....HansV wrote:Yes, I understand, but how do you read the line in VBA?
yes in vba for excel for first test and in official project with vb6 classic.
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SUBSTITUITE hex chr with other ...
Please, can you show us the bit of code that you use to read the string?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: SUBSTITUITE hex chr with other ...
Sub LEGGI()HansV wrote:Please, can you show us the bit of code that you use to read the string?
Dim sFileText As String
Dim iFileNo As Integer
iFileNo = FreeFile
Open "C:\TEMP\mytestfile.txt" For Input As #iFileNo
Do While Not EOF(iFileNo)
Input #iFileNo, sFileText
Loop
Close #iFileNo
End Sub
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SUBSTITUTE hex chr with other ...
Sal, the text file that you sent me doesn't contain Chr(0) (except for the very last character):
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans