473,700 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert textbox contents to files

How would I convert the contents of a textbox into text files.

Say I have a textbox containin the following...
13-02-00 - Paul Oakenfold
06-02-00 - William Orbit
30-01-00 - Laurent Garnier
23-01-00 - Guy Ornadel
16-01-00 - Dave Clarke
09-01-00 - Scott Bond
02-01-00 - Mr C
I would like to loop thru the textbox and need each line to be saved as a
text file under that name. So I would end up with 7 blank text files e.g....

13-02-00 - Paul Oakenfold.txt
06-02-00 - William Orbit.txt
30-01-00 - Laurent Garnier.txt
23-01-00 - Guy Ornadel.txt
16-01-00 - Dave Clarke.txt
09-01-00 - Scott Bond.txt
02-01-00 - Mr C.txt

I've tried getting the contents of the textbox

Thanks....

Jul 17 '05 #1
2 3767
Here's one way....

Needs a command button
'============== ===
Option Explicit

Private Sub Command1_Click( )
Const START_PATH = "C:\Temp\"
Dim sFullPath As String
Dim v As Variant
Dim i As Integer
Dim iFile As Integer

'Split the contents into an array
v = Split(Text1.Tex t, vbCrLf)
iFile = FreeFile

For i = 0 To UBound(v)
If Len(v(i)) > 0 Then
iFile = FreeFile
sFullPath = START_PATH & v(i)
Debug.Print "Creating " & sFullPath & " ...."
Open sFullPath For Output As iFile
Close iFile
End If
Next
Debug.Print "Done"

End Sub

Private Sub Form_Load()
Text1.Text = ""
Text1.SelText = "13-02-00 - Paul Oakenfold.txt" & vbCrLf
Text1.SelText = "06-02-00 - William Orbit.txt" & vbCrLf
Text1.SelText = "30-01-00 - Laurent Garnier.txt" & vbCrLf
Text1.SelText = "23-01-00 - Guy Ornadel.txt" & vbCrLf
Text1.SelText = "16-01-00 - Dave Clarke.txt" & vbCrLf
Text1.SelText = "09-01-00 - Scott Bond.txt" & vbCrLf
Text1.SelText = "02-01-00 - Mr C.txt" & vbCrLf

End Sub
'============== ===

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep it in the groups..
"Paul" <12************ **@btinternet.c om> wrote in message
news:bj******** **@sparta.btint ernet.com...
How would I convert the contents of a textbox into text files.

Say I have a textbox containin the following...
13-02-00 - Paul Oakenfold
06-02-00 - William Orbit
30-01-00 - Laurent Garnier
23-01-00 - Guy Ornadel
16-01-00 - Dave Clarke
09-01-00 - Scott Bond
02-01-00 - Mr C
I would like to loop thru the textbox and need each line to be saved as a
text file under that name. So I would end up with 7 blank text files e.g....

13-02-00 - Paul Oakenfold.txt
06-02-00 - William Orbit.txt
30-01-00 - Laurent Garnier.txt
23-01-00 - Guy Ornadel.txt
16-01-00 - Dave Clarke.txt
09-01-00 - Scott Bond.txt
02-01-00 - Mr C.txt

I've tried getting the contents of the textbox

Thanks....


Jul 17 '05 #2
Thanks Ken, works a treat.

"Ken Halter" <Ken_Halter@Use _Sparingly_Hotm ail.com> wrote in message
news:#S******** ******@TK2MSFTN GP09.phx.gbl...
Here's one way....

Needs a command button
'============== ===
Option Explicit

Private Sub Command1_Click( )
Const START_PATH = "C:\Temp\"
Dim sFullPath As String
Dim v As Variant
Dim i As Integer
Dim iFile As Integer

'Split the contents into an array
v = Split(Text1.Tex t, vbCrLf)
iFile = FreeFile

For i = 0 To UBound(v)
If Len(v(i)) > 0 Then
iFile = FreeFile
sFullPath = START_PATH & v(i)
Debug.Print "Creating " & sFullPath & " ...."
Open sFullPath For Output As iFile
Close iFile
End If
Next
Debug.Print "Done"

End Sub

Private Sub Form_Load()
Text1.Text = ""
Text1.SelText = "13-02-00 - Paul Oakenfold.txt" & vbCrLf
Text1.SelText = "06-02-00 - William Orbit.txt" & vbCrLf
Text1.SelText = "30-01-00 - Laurent Garnier.txt" & vbCrLf
Text1.SelText = "23-01-00 - Guy Ornadel.txt" & vbCrLf
Text1.SelText = "16-01-00 - Dave Clarke.txt" & vbCrLf
Text1.SelText = "09-01-00 - Scott Bond.txt" & vbCrLf
Text1.SelText = "02-01-00 - Mr C.txt" & vbCrLf

End Sub
'============== ===

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep it in the groups..
"Paul" <12************ **@btinternet.c om> wrote in message
news:bj******** **@sparta.btint ernet.com...
How would I convert the contents of a textbox into text files.

Say I have a textbox containin the following...
13-02-00 - Paul Oakenfold
06-02-00 - William Orbit
30-01-00 - Laurent Garnier
23-01-00 - Guy Ornadel
16-01-00 - Dave Clarke
09-01-00 - Scott Bond
02-01-00 - Mr C
I would like to loop thru the textbox and need each line to be saved as a text file under that name. So I would end up with 7 blank text files e.g....
13-02-00 - Paul Oakenfold.txt
06-02-00 - William Orbit.txt
30-01-00 - Laurent Garnier.txt
23-01-00 - Guy Ornadel.txt
16-01-00 - Dave Clarke.txt
09-01-00 - Scott Bond.txt
02-01-00 - Mr C.txt

I've tried getting the contents of the textbox

Thanks....



Jul 17 '05 #3

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

Similar topics

6
12734
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
6
2249
by: Ketta | last post by:
I know how to read a file system object and output it to the browser page. The desired result would be to put that file into a textbox on the screen for a user to modify and then write the file back to the file system. The concept seems simple enough, read the text file into a variable then some magic asp will put it into a textbox value, then somehow take that value and write the file. I know how to write files to the system as well. I...
27
51714
by: Trep | last post by:
Hi there! I've been having a lot of difficult trying to figure out a way to convert a terminated char array to a system::string for use in Visual C++ .NET 2003. This is necessary because I have some legcay C code that needs to process a string taken from a textbox, then I need to re-display the string as the textbox->Text. I easily found how to convert from system::string to char but I can't figure out how to go the other way!!
5
2725
by: manmit.walia | last post by:
Hello All, I am stuck on a conversion problem. I am trying to convert my application which is written in VB.NET to C# because the project I am working on currently is being written in C#. I tried my best to convert it, but somehow the app does not work. I am also not getting any errors when I complie thus, letting me know I am on the write track. Basically what I want to do is edit,add,delete, and update an XML file in a DataGrid. Below...
1
3164
by: jon.ingram | last post by:
I need some vb code that I could perhaps run from access that will look in a particular folder I could specify in the code, and convert all the files (just excel are saved there) to .csv. Is this possible? This would be a huge help for me and any help would be greatly appreciated. Also, there are only 5 files in the folder (the folder path never changes) but they are updated monthly so if we cant evaluate the entire
4
10456
by: Davor | last post by:
Hi, my name is david. I need to read information from .pdf files and convert to .txt files, and I have to do this on python, I have been looking for libraries on python and the pdftools seems to be the solution, but I do not know how to use them well, this is the example that I found on the internet is: from pdftools.pdffile import PDFDocument from pdftools.pdftext import Text
2
9875
by: garyusenet | last post by:
I have a multi line text box, i'd like to store the contents of this textbox to a text file. However when I write the value of ' textbox.text ' to the file it is written verbatim spanning many lines if enter has been pressed. I'd like to store the value of the textbox on one single line in the file. How do i do this? I assume i'll need to read new line characters from the textbox.text string, and replace them with some token ?
7
2892
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt enough memory' error whenever I scroll past N number of bytes in a textbox that has been filled with a lot of data. I am not sure what N is, but for a large chunk of data it occurs at about the halfway scroll, and smaller chunks might not throw...
0
10767
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8718
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
8642
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
9066
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8963
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
8916
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...
0
4400
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3083
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
2383
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.