474,028 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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 3136
se*********@gma il.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*********@gma il.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*********@gma il.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
2915
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 no luck though), and searched through the IRT.ORG Faqs (www.irt.org/script/script.htm). The Javascript is designed to open an popup window and then inside that window call another script which will resize that window. There may be another...
385
17629
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 extraneous jargons, such as in the Unix & Perl community. Unlike mathematicians, where in mathematics there are no fewer jargons but each and every one are
2
3084
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 array). I cannot change anything in the program but can add some features by which I can convert this array of data into a file. The easiest thing would be to write the data into a file (in hard disk) and use it. But I will be working on thousands...
7
3723
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 satisfactory answer (check your browser) so now that I've had the time to set up a reasonable little test that I can post somewhere, I'll try again. The app I've written has three ASPX pages. One is a combined page which writes a little text...
2
1614
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 am trying to use the following code to write but this is not working properly. outfilew.Write(group6) outfilew.Write(Environment.NewLine) If I take the data and convert it to unix thru a utility it then works properly.
6
5296
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
5512
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 working with very large files. of course, if there is any other way to write data to a file, i'd love to hear about it
2
4579
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 getting on more or less OK. So far, I have managed to parse my tab-delimited .txt file properly into an array, and then use this array to update the tags on a bunch of MP3 audio files. Nice.
6
7541
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 efficiently, I draw the text directly to the image. It's faster that way. The problem is that right now I have to redraw the original (unwritten-to) bitmap and redraw the text whenever the user moves the text because I haven't figured out how to properly...
0
10507
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12083
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11930
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11099
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8653
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4908
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.