Export Data to Notepad

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 9
Reputation: Evil03 is an unknown quantity at this point 
Solved Threads: 0
Evil03 Evil03 is offline Offline
Newbie Poster

Export Data to Notepad

 
0
  #1
Jan 2nd, 2009
Hi All,

I have created a Vb.net application with back as MS.Access..I shall be very thankful if someone pls guide me on how to EXPORT DATA from the VB>NET Textboxes to NOTEPAD..

THe methof that i am using is creating a CSV file which is can Adjust in excel after copying data from notepad to excel...

BUT MY CUSTOMER WANTS SOMETHINGS LIKE BELOW PATTERN
  1. NAME POSITION COUNSELE BY DATE
  2. abc abc abc 123
  3. xyz xyz xyz 123
  4. aaa aaa aaa 123
Pls help me to fix this issue.....

Below is my code
  1. Private Sub btnnotepad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnotepad.Click
  2.  
  3.  
  4. Dim filename As String = "C:\Documents and Settings\Acer\Desktop\CounsellingSystem\Counsellrecords.txt"
  5.  
  6. Dim lineoftext As String
  7. Dim arytext(5) As String
  8.  
  9.  
  10. arytext(0) = txtname.Text
  11. arytext(1) = txtnpos.Text
  12. arytext(2) = txtcname.Text
  13. arytext(3) = txtcpos.Text
  14. arytext(4) = DateTimePickerdoc.Value.ToShortDateString
  15. arytext(5) = DateTimePickerrd.Value.ToShortDateString
  16.  
  17. lineoftext = String.Join(";", arytext)
  18.  
  19. Dim objwriter As New System.IO.StreamWriter(filename, True)
  20. objwriter.WriteLine(lineoftext)
  21.  
  22. objwriter.Close()
  23.  
  24. MsgBox("Record Saved To Notepad")
  25.  
  26. End Sub
Million thanks
Last edited by Narue; Jan 5th, 2009 at 9:30 am. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 36
Reputation: Alexpap is an unknown quantity at this point 
Solved Threads: 0
Alexpap Alexpap is offline Offline
Light Poster

Re: Export Data to Notepad

 
0
  #2
Jan 2nd, 2009
what's the error code when you run this?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Export Data to Notepad

 
0
  #3
Jan 2nd, 2009
Why export it to notepad, and then copy/paste into excel, when you could have the VB program automatically add it to excel?
--------------------------------------------------
replace lineoftext = join with this:
  1. lineoftext = txtname.text & "," & txtpos.text & "," & txtcname.text & "," & DateTimePickerdoc.Value.ToShortDateString
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 9
Reputation: Evil03 is an unknown quantity at this point 
Solved Threads: 0
Evil03 Evil03 is offline Offline
Newbie Poster

Re: Export Data to Notepad

 
0
  #4
Jan 2nd, 2009
Hi Thanks For so quick responses

My coding saves the data in this format...

****************************
NAME; POSITION ;COUNSELOR; DATE
abc;sdf;rtt;123
xyz;edc;tgb;123
qsr;fgv;vgh;123
*****************************

but,

My Customer needs data in below format

************************************
NAME POSITION COUNSELE BY DATE
abc abc abc 123
xyz xyz xyz 123
aaa aaa aaa 123
***************************************

The customer doesnt want to see the data in excel.. they just want the txt file to diplay the data from vb.net in the above mentioned pattern..

I beleive i need to define lengths & Positions in notepad..but problem is i am blur on how to define lengths and positions of text......I would really appreciate if u guys could pls help me out of this issue

Thanks again for helping
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Export Data to Notepad

 
0
  #5
Jan 2nd, 2009
The only way to really format data in notepad, is to use tabs. Say,
name <tab><tab>Position<tab><tab>Counseled by date
which is easy enough with:
  1. lineoftext = txtname.text & vbtab & vbtab & txtpos.text & vbtab & vbtab & txtcname.text & vbtab & vbtab & DateTimePickerdoc.Value.ToShortDateString
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 9
Reputation: Evil03 is an unknown quantity at this point 
Solved Threads: 0
Evil03 Evil03 is offline Offline
Newbie Poster

Re: Export Data to Notepad

 
0
  #6
Jan 4th, 2009
Originally Posted by Comatose View Post
The only way to really format data in notepad, is to use tabs. Say,
name <tab><tab>Position<tab><tab>Counseled by date
which is easy enough with:
  1. lineoftext = txtname.text & vbtab & vbtab & txtpos.text & vbtab & vbtab & txtcname.text & vbtab & vbtab & DateTimePickerdoc.Value.ToShortDateString
Hi Comatose ,
Dude Thanks Millions for such a great help But the issue is still the same i can GIve spaces using VBTAB ...but the space is not saving documents in porper format....

Means
The colums n rows are not same for the record Meaning:
1-UNder name MAX then i want to leave spaces in the between then Counselor name is George
2 - William then i want to leave spaces in the between then Coounselor name is Matt....

Ples Refer to attachment

PLS Would Appreciate ur Help alot if u can help me on this matter.
Attached Files
File Type: txt Counsellrecords.txt (1.1 KB, 7 views)
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Export Data to Notepad

 
0
  #7
Jan 4th, 2009
This Site will help you out a great deal. The best way to do this is something like:
  1. Dim oFile as System.IO.File
  2. Dim oWrite as System.IO.StreamWriter
  3. oWrite = oFile.CreateText(“C:\sample.txt)
  4. oWrite.WriteLine({0,10}{1,10}{2,25}”, “Date”, “Time”, “Price”)
  5. oWrite.WriteLine({0,10:dd MMMM}{0,10:hh:mm tt}{1,25:C}”, Now(), 13455.33)
  6. oWrite.Close()
Here, if you mess with the numbers that are inside the {}, you can adjust exactly where in the text file you want the data to go....If this solution doesn't work (but it should) we can try one more (ugly) way.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Export Data to Notepad

 
0
  #8
Jan 5th, 2009
Yeah you could use the above method or another one:

pad the strings:

Dim str1 As String = "My String"
Console.WriteLine(str1.PadLeft(20, "-"))
Dim str2 As String = "My String"
Console.WriteLine(str2.PadRight(20, "-"))


I guess the key is to find out the length of the longest word in each column and make sure the padding is that length minimum. Pretty simple really.


The only real problem I see is if the customer wants to then open this notepad file as an excel file (right click, open as, excel). That obviously wouldn't work...
Last edited by iamthwee; Jan 5th, 2009 at 6:34 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 9
Reputation: Evil03 is an unknown quantity at this point 
Solved Threads: 0
Evil03 Evil03 is offline Offline
Newbie Poster

Re: Export Data to Notepad

 
0
  #9
Jan 6th, 2009
Originally Posted by Comatose View Post
This Site will help you out a great deal. The best way to do this is something like:
  1. Dim oFile as System.IO.File
  2. Dim oWrite as System.IO.StreamWriter
  3. oWrite = oFile.CreateText(“C:\sample.txt)
  4. oWrite.WriteLine({0,10}{1,10}{2,25}”, “Date”, “Time”, “Price”)
  5. oWrite.WriteLine({0,10:dd MMMM}{0,10:hh:mm tt}{1,25:C}”, Now(), 13455.33)
  6. oWrite.Close()
Here, if you mess with the numbers that are inside the {}, you can adjust exactly where in the text file you want the data to go....If this solution doesn't work (but it should) we can try one more (ugly) way.

Hi Guys Thanks for sharing Valuable information.
With ur Precious Help & time , my problem is HALF SOLVED


My Project will be completed if i can overcome this problem through valuable help from u guys.

Below is the coding:
***************************************************

Private Sub btnnotepad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnotepad.Click

Dim filename As String = "C:\Documents and Settings\Acer\Desktop\CounsellingSystem\Counsellrecords.txt"

Dim objwriter As New System.IO.StreamWriter(filename, True)

objwriter.WriteLine("{0,5}{1,30}{2,15}{3,15}{4,15}{5,15}", txtname.Text, txtnpos.Text, txtcname.Text, txtcpos.Text, DateTimePickerdoc.Value.ToShortDateString, DateTimePickerrd.Value.ToShortDateString)

objwriter.Close()

MsgBox("Record Saved To Notepad")

End sub

******************************************************

Please See attachment
Attached Files
File Type: txt Counsellrecords.txt (1.1 KB, 6 views)
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 9
Reputation: Evil03 is an unknown quantity at this point 
Solved Threads: 0
Evil03 Evil03 is offline Offline
Newbie Poster

Re: Export Data to Notepad

 
0
  #10
Jan 12th, 2009
Hi All,

My sincere thanks to everyone for sharing their thoughts and assisting me in completing my project.

With all the valuable help from u guys my PROJECT is COMPLETED ..

Thanks
Evil
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC