From: dpb on 19 Jun 2010 19:54 mp wrote: > "Mike Williams" <Mike(a)WhiskeyAndCoke.com> wrote in message > news:OhHN09%23DLHA.588(a)TK2MSFTNGP06.phx.gbl... >> "mp" <nospam(a)Thanks.com> wrote in message >> news:eX9eXs9DLHA.1868(a)TK2MSFTNGP05.phx.gbl... >> >>> . . . but it prints one blank line...how >>> to just end up with a blank file? >> Print #iFhndl, sMsg; >> >> Mike >> > is that a semicolon at the end? > that wouln't print the blank line i'm getting now? It would print whatever is the content of sMsg w/o the following cr/lf. If it's an empty string you'll get a blank line I believe (altho I didn't test it, pretty sure is so). As noted upthread just open the file w/o APPEND and will end up w/ a truncated file if exists, new empty file if not. --
From: mp on 19 Jun 2010 20:03 "dpb" <none(a)non.net> wrote in message news:hvjlfp$njt$2(a)news.eternal-september.org... > mp wrote: >> "Mike Williams" <Mike(a)WhiskeyAndCoke.com> wrote in message >> news:OhHN09%23DLHA.588(a)TK2MSFTNGP06.phx.gbl... >>> "mp" <nospam(a)Thanks.com> wrote in message >>> news:eX9eXs9DLHA.1868(a)TK2MSFTNGP05.phx.gbl... >>> >>>> . . . but it prints one blank line...how >>>> to just end up with a blank file? >>> Print #iFhndl, sMsg; >>> >>> Mike >>> >> is that a semicolon at the end? >> that wouln't print the blank line i'm getting now? > > It would print whatever is the content of sMsg w/o the following cr/lf. If > it's an empty string you'll get a blank line I believe (altho I didn't > test it, pretty sure is so). > > As noted upthread just open the file w/o APPEND and will end up w/ a > truncated file if exists, new empty file if not. > > -- Right, saw that, sweet Thanks to all mark
From: Mike Williams on 20 Jun 2010 02:37 "mp" <nospam(a)Thanks.com> wrote in message news:OH5gznAELHA.5736(a)TK2MSFTNGP02.phx.gbl... >> "Mike Williams" <Mike(a)WhiskeyAndCoke.com> wrote in message >> news:OhHN09%23DLHA.588(a)TK2MSFTNGP06.phx.gbl... >> Print #iFhndl, sMsg; > > is that a semicolon at the end? Yes. > that wouln't print the blank line i'm getting now? No. It would print the contents of whatever string you were passing to your OverWrite function, which in the specific example you posted is an empty string, and so it would therefore not print anything, effectively clearing the file to an empty file because it had been opened for Output. You could of course achieve exactly the same effect simply by Opening the file for Output and then closing it without using any Print statement at all, as has already been suggested. The reason I suggested using a semicolon at the end of the print statement in your own existing Overwrite function is because I assumed that you are still going to use that function as a general method of deleting the contents of the file and replacing them with the contents of the string you are passing to it, and so I wanted to inform you of exactly what VB would write to the file when you pass it other non empty strings. Most importantly though, I wanted to provide you with a solution that made you aware of the behaviour of the VB Print method in those circumstances, which can be very important in other similar circumstances, especially when you Print multiple substrings to a file one after the other as you will almost certainly want to do in many cases. When you use Print to print something to a file then it prints the string to the file and it also prints a vbCrLf pair (Chr(13) followed by Chr(10)) to the file immediately after the string. It is that vbCrLf which is causing your file to have what you have called a "blank line". However, if you add a semi colon at the end of your Print statement as shown above then it supresses the printing of the otherwise automatic trailing vbCrLf. When you are writing stuff to files using the VB Print statement, especially if you are writing various different pieces of text in succession one after the other, then it is important that you know about the behaviour of the Print method and take that behaviour into account, using a semicolon at the end of any Print statement where you wish to suppress the otherwise automatic printing of a vbCrLf. Mike
From: mp on 20 Jun 2010 12:00 "Mike Williams" <Mike(a)WhiskeyAndCoke.com> wrote in message news:eCNVCMEELHA.5724(a)TK2MSFTNGP05.phx.gbl... > "mp" <nospam(a)Thanks.com> wrote in message > news:OH5gznAELHA.5736(a)TK2MSFTNGP02.phx.gbl... >>> "Mike Williams" <Mike(a)WhiskeyAndCoke.com> wrote in message >>> news:OhHN09%23DLHA.588(a)TK2MSFTNGP06.phx.gbl... >>> Print #iFhndl, sMsg; >> >> is that a semicolon at the end? > > Yes. > >> that wouln't print the blank line i'm getting now? > > No. It would print the contents of whatever string you were passing to > your OverWrite function, which in the specific example you posted is an > empty string, and so it would therefore not print anything, effectively > clearing the file to an empty file because it had been opened for Output. > You could of course achieve exactly the same effect simply by Opening the > file for Output and then closing it without using any Print statement at > all, as has already been suggested. > > The reason I suggested using a semicolon at the end of the print statement > in your own existing Overwrite function is because I assumed that you are > still going to use that function as a general method of deleting the > contents of the file and replacing them with the contents of the string > you are passing to it, and so I wanted to inform you of exactly what VB > would write to the file when you pass it other non empty strings. Most > importantly though, I wanted to provide you with a solution that made you > aware of the behaviour of the VB Print method in those circumstances, > which can be very important in other similar circumstances, especially > when you Print multiple substrings to a file one after the other as you > will almost certainly want to do in many cases. > > When you use Print to print something to a file then it prints the string > to the file and it also prints a vbCrLf pair (Chr(13) followed by Chr(10)) > to the file immediately after the string. It is that vbCrLf which is > causing your file to have what you have called a "blank line". However, if > you add a semi colon at the end of your Print statement as shown above > then it supresses the printing of the otherwise automatic trailing vbCrLf. > When you are writing stuff to files using the VB Print statement, > especially if you are writing various different pieces of text in > succession one after the other, then it is important that you know about > the behaviour of the Print method and take that behaviour into account, > using a semicolon at the end of any Print statement where you wish to > suppress the otherwise automatic printing of a vbCrLf. > > Mike > awesome Mike, thank you. is that an undocumented trick? I don't see it in the help. now that i look again i see the ; used as a separator for different values in one print statement but didn't realize what it was effectively doing. thanks mark
From: Larry Serflaten on 20 Jun 2010 13:02 "mp" <nospam(a)Thanks.com> wrote > awesome Mike, thank you. > is that an undocumented trick? I don't see it in the help. Its there. Read the text for 'charpos'. The exact wording is: "Use a semicolon to position the insertion point immediately after the last character displayed." http://msdn.microsoft.com/en-us/library/aa266187(VS.60).aspx <g> LFS
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Use Internet to network to VB5 app? Next: Using the info zip dll |