Quantcast
Channel: VB 2010 Progress Bar.
Viewing all articles
Browse latest Browse all 41

VB 2010 Progress Bar.

$
0
0
I could not find out or understand the way of "Overriding" the OpenTextFile method.  Also, ANSI was not listed in the encoding list.

The site reference that I provided is the override for the method that allows you to specify the encoding that you need:

http://msdn.microsoft.com/en-us/library/ms128024(v=VS.80).aspx
FileSystem.OpenTextFileWriter Method (String, Boolean, Encoding)

It should appear as an option as soon as you get to the '(' when you type the method name.  Which ones did you try and what was the effect?

If ANSI is not listed as an available encoding, that should tell you something about Notepad.  I suspect that you will find it is actually ASCII (standard 7-bit characters) in the current codepage.

I also took the batch file that VB made, opened it with notepad, Saved As, but changed the encoding to ANSI, and it worked the way it was suppose to, with the Echo Off.

So, if you examine the file that works, and you examine the file that doesn't work, what is the difference that you can detect between them?   You might be able to work this out by finding what ANSI means for Notepad and what the default encoding is for Notepad,  but as it is a very old utility, that might be difficult, and it seems like the hard way to go about it.  I suspect, hpwever, that ANSI actually means 'None" as far as Notepad is concerned - that is, do not include any encoding at all, and do not indicate that the file is written with any encoding.  If you look at the files and compare them, you may find the difference in the first two bytes. The reason I suspect that is that the difference in the way the file executes appears to apply to the first line only.  

But when I change the encoding to UTF-8, and even though I still had "@Echo Off" at the top.  It seemed as if it was on.  So it showed the command when it was ran, and it would show the directories.

I also took the batch file that VB made, opened it with notepad, Saved As, but changed the encoding to ANSI, and it worked the way it was suppose to, with the Echo Off.

What happens if you include @Echo Off twice?  As the problem appears to affect that line only, you should test whether it is the position in the file (ie, as first line) that is the differentiating factor.  If it is, then your first line should be a dummy command (CD . is a good one).  Why fight a problem when you can work around it with just a simple change?  

Now do the same thing again but this time change the encoding to UTF-8.

Run them, and compare them.

I am not doubting that the two files behave differently when used like that.  But it's not sufficient to know that they appear to be different as far as the batch file processor is concerned - you need to know what the actual difference in the file is. To do that you need to examine the file at the byte level.  Or, just experiment with different encodings and see what the effect is.


Viewing all articles
Browse latest Browse all 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>