VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,344 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,567 people online right now. Registration is fast and FREE... Join Now!




How do i copy an output into a text document?

 

How do i copy an output into a text document?

PotatoZOMBIE

2 Jul, 2009 - 09:03 AM
Post #1

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 8


My Contributions
Right, below is what i have made so far, the user can enter their name, age, and address which is all that i want, then when they click submit, their info is shown in the output box, which is situated underneath the submit button.

But i want to also copy this user info to an external text document when they have clicked submit, anybody think they know how?

IPB Image

CODE
Public Class Form1

    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
        Dim Name As String
        Dim Age As Integer
        Dim Address As String
        Dim Output

        Name = txtName.Text
        Age = txtAge.Text
        Address = txtAddress.Text

        Output = ""

        Output = Name & vbCrLf & _
        Age & vbCrLf & _
        Address

        txtOutput.Text = Output


    End Sub
End Class


Thanx all x

This post has been edited by PotatoZOMBIE: 2 Jul, 2009 - 09:04 AM

User is offlineProfile CardPM
+Quote Post


PsychoCoder

RE: How Do I Copy An Output Into A Text Document?

2 Jul, 2009 - 09:06 AM
Post #2

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,704



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Moved to VB.NET smile.gif
User is offlineProfile CardPM
+Quote Post

CamoDeveloper

RE: How Do I Copy An Output Into A Text Document?

2 Jul, 2009 - 09:21 AM
Post #3

D.I.C Head
Group Icon

Joined: 12 Jun, 2009
Posts: 204



Thanked: 12 times
Dream Kudos: 200
My Contributions
I think this is what you're looking for:
CODE

Public Class Form1
    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
        Dim Name As String = ""
        Dim Age As Integer = 0
        Dim Address As String = ""
        Dim Output As String = ""
        Dim fileLoc As String = "C:\test.txt"

        Name = txtName.Text
        Age = txtAge.Text
        Address = txtAddress.Text

        Output = Name & vbCrLf & _
        Age & vbCrLf & _
        Address

        txtOutput.Text = Output

        If File.Exists(fileLoc) Then
            Using sw As StreamWriter = New StreamWriter(fileLoc)
                sw.Write(Output)
            End Using
        End If
    End Sub
End Class


~Camo

This post has been edited by CamoDeveloper: 2 Jul, 2009 - 09:22 AM
User is offlineProfile CardPM
+Quote Post

PotatoZOMBIE

RE: How Do I Copy An Output Into A Text Document?

2 Jul, 2009 - 09:25 AM
Post #4

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 8


My Contributions
Sorry about that, Whats the difference between VB6 and .Net?

QUOTE(CamoDeveloper @ 2 Jul, 2009 - 09:21 AM) *

I think this is what you're looking for:
CODE

Public Class Form1
    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
        Dim Name As String = ""
        Dim Age As Integer = 0
        Dim Address As String = ""
        Dim Output As String = ""
        Dim fileLoc As String = "C:\test.txt"

        Name = txtName.Text
        Age = txtAge.Text
        Address = txtAddress.Text

        Output = Name & vbCrLf & _
        Age & vbCrLf & _
        Address

        txtOutput.Text = Output

        If File.Exists(fileLoc) Then
            Using sw As StreamWriter = New StreamWriter(fileLoc)
                sw.Write(Output)
            End Using
        End If
    End Sub
End Class


~Camo


Cheers for that mate =)

Say i wanted to store this info not in a text file but in a database so i could come back and retrieve it if i wanted to, what would i need to do in order to do that?
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: How Do I Copy An Output Into A Text Document?

2 Jul, 2009 - 09:25 AM
Post #5

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,704



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
@PotatoZOMBIE:

Take a look at this for the differences between the 2 smile.gif
User is offlineProfile CardPM
+Quote Post

PotatoZOMBIE

RE: How Do I Copy An Output Into A Text Document?

3 Jul, 2009 - 03:12 AM
Post #6

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 8


My Contributions
Anyway i could copy that info into a database then guys/girls? Instead of copying it into a text document?
User is offlineProfile CardPM
+Quote Post

LoveIsNull

RE: How Do I Copy An Output Into A Text Document?

3 Jul, 2009 - 04:30 AM
Post #7

Disbanding my Ignorance
****

Joined: 10 Mar, 2009
Posts: 536



Thanked: 45 times
My Contributions
Perhaps. Look here.
User is offlineProfile CardPM
+Quote Post

PotatoZOMBIE

RE: How Do I Copy An Output Into A Text Document?

10 Jul, 2009 - 08:13 AM
Post #8

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 8


My Contributions
Ive decided to just put it into a text document for now as i looked at that url LoveIsNull and it all looks to complicated so im thinking once i have it in my text document im just gonna put it into excel or access from my text file, might seem a long winded way of doing it but at least ill know what im doing, thankyou anyway LoveIsNull
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 05:51PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month