Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 29th, 2011, 03:11 PM
Registered User
 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Writing Text Boxes to Files: Formatting and Headers?

Hello.

I'm working on my very first VB 2008 Express program, having a little bit of experience with VB 6. The two are radically different, so I'm respectfully requesting just a little bit of help.

For my first VB 2008 program, I'm starting out simple. I have two text boxes, named Title and Director. You input text into each text box.
I also have a button named GENERATE, which generates a text file named c:\test.txt and stores the text box material.

Here is the code I've used for the GENERATE button:

Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter("c:\test .txt", True)
file.Write(Title)
file.Write(Director)
file.Close()
MessageBox.Show("Your file has been created.")


It took a considerable amount of research to figure out how to do something as rudimentary as this. Like I said, this is much different than VB 6.

Here is what the text file's contents look like:

System.Windows.Forms.TextBox, Text: Full Metal JacketSystem.Windows.Forms.TextBox, Text: Stanley Kubrick

The above text is all in one line.

What I want to do is format the text file a certain way. I want the text to look like this:

Title: Full Metal Jacket

Director: Stanley Kubrick


And so on. I want the lines double-spaced.

I know how to do this with VB 6, but not with VB 2008, and my research hasn't come up with an explanation of how to format this correctly.

So…how do I revise this code so that there is a line for each text box string, how do I get rid of the System.Windows.Forms.TextBox stuff and replace it with my own headers, and how do I double-space between lines?

I realize this is probably rudimentary stuff, but for someone migrating to VB 2008 or 2010, it's a challenge. Thank you for any assistance you care to give. J. Danniel
 
Old May 30th, 2011, 09:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there...

Try with WriteLine (it will write a new line char at the end of the string..)... Also, if title is an object, you have to send title.text, there are no default properties on .net, so it's just sending the type of object it has...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Boxes: Writing Results to Text File and Formatting Properly jdanniel Beginning VB 6 1 May 29th, 2011 08:55 PM
Creating, Writing to and Deleting Text Files goels Access VBA 7 January 30th, 2007 11:51 AM
Dynamic check boxes writing to database..help!! cincinnaticj7 Classic ASP Databases 0 January 25th, 2005 10:47 AM
Formatting Message Boxes Magic_Hat Excel VBA 1 June 21st, 2004 10:13 AM
Headers to Open and display files AAA PHP How-To 1 March 17th, 2004 09:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.