|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
writing a text in a file in vb.net not working properlyi am not able to write a text properly in a text file in vb.net.below is the code that i have written. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim counter As Integer FileOpen(1, "c:\sample.txt", OpenMode.Random, , , 50) For Counter = 1 To 5 FilePut(1, "ganesh", counter) Next Counter FileClose(1) End Sub. The output of the code is "? ganesh ? ganesh ? ganesh ? ganesh ? ganesh" i am not able to understand why this symbol gets displayed "?".is there any solution for this ? Thanks, Ganesh sethugan***@gmail.com wrote:
> i am not able to write a text properly in a text file in vb.net.below <snip code using FilePut>> is the code that i have written. > i am not able to understand why this symbol gets displayed "?".is FilePut isn't intended for writing text files - it's more for writing to> there any solution for this ? files that will be read back with FileGet. For VB functions to do what you appear to want, see the docs for Write and WriteLine. Andrew hi,
i am using FileGet function to read the file.but i want to know why the symbol "? ? " gets displayed while writing into file. Thanks, Ganesh Andrew Morton wrote: Show quoteHide quote > sethugan***@gmail.com wrote: > > i am not able to write a text properly in a text file in vb.net.below > > is the code that i have written. > <snip code using FilePut> > > i am not able to understand why this symbol gets displayed "?".is > > there any solution for this ? > > FilePut isn't intended for writing text files - it's more for writing to > files that will be read back with FileGet. For VB functions to do what > you appear to want, see the docs for Write and WriteLine. > > Andrew sethugan***@gmail.com wrote:
> i am using FileGet function to read the file.but i want to know why Read the docs for FilePut for clues, e.g.> the symbol "? ? " gets displayed while writing into file. "If the variable being written is a string, FilePut writes a two-byte descriptor containing the string length, and then writes the data that goes into the variable. Therefore, the record length specified by the RecordLength clause in the FileOpen function must be at least two bytes greater than the actual length of the string." And, knowing that it isn't actually a text file, you should be using a hex editor to examine the content of the file. HTH Andrew
changing the date format in vb.net
Calling a batch file from vb.net with parameters Streaming a file to text? How to force upper case in a DataGridView column? Dealing with NULL values in Integer fields Mulples threads and impersonation What's the Best Startup Scenario for Unattended Server Execution? VB.net 2005 splash screen Handle pointers from delphi client to a vb.net dll Count Rcords |
|||||||||||||||||||||||