473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

writing a text in a file in vb.net not working properly

hi,

i 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

Jun 15 '06 #1
3 3097
se*********@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

Jun 15 '06 #2
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:
se*********@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


Jun 15 '06 #3
se*********@gmail.com wrote:
i am using FileGet function to read the file.but i want to know why
the symbol "  " gets displayed while writing into file.


Read the docs for FilePut for clues, e.g.
"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

Jun 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Robby Bankston | last post by:
I'm working on some code and am running into brick walls. I'm trying to write out Javascript with Javascript and I've read the clj Meta FAQ and didn't see the answer, read many similar posts (with...
385
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like...
2
by: Jeevan | last post by:
Hi, I have an array of data (which I am getting from a socket connection). I am working on a program which acts on this data but the program is written to work on data from a file (not from an...
7
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a...
2
by: Lyle A. Sieren | last post by:
Hello! Sorry...I accidentally posted the last message before finishing it. How do you write a file in unix format from vb.net? I need it in unix format to complete a CIM load in Progress. I...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
5
by: montyphyton | last post by:
as i understand there are two ways to write data to a file: using f.write("foo") and print >>f, "foo". what i want to know is which one is faster (if there is any difference in speed) since i'm...
2
by: Clive Green | last post by:
Hello peeps, I am using PHP 5.2.2 together with MP3_Id (a PEAR module for reading and writing MP3 tags). I have been using PHP on the command line (Mac OS X Unix shell, to be precise), and am...
6
by: bradyounie | last post by:
I'm writing a program that displays a user-supplied Bitmap and then writes text fields to it. These "text fields" are things that the user can move around on the image, but to render them...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.