Hey
I have three text box's on a form called form4. The text box's are called txtCustomerID, txtCustomerName and txtTelephoneNo. How do I copy the cells and save them in notepad. I also want the notepad file to be saved as whatever is in the txtCustomerId text box so the next time a file is saved it does'nt replace the existing one.
Thanks for any help
G
You have to create a text file, open it right out the values and then save it. You could use the FSO object(among other ways to do it).
regards
jcd
meteo 12-11-2002, 12:12 PM Originally posted by GWO
Hey
I have three text box's on a form called form4. The text box's are called txtCustomerID, txtCustomerName and txtTelephoneNo. How do I copy the cells and save them in notepad. I also want the notepad file to be saved as whatever is in the txtCustomerId text box so the next time a file is saved it does'nt replace the existing one.
Thanks for any help
G
Here's just a basic throw out for ya:
Dim strCid as string 'set variable
Dim strCname as string 'set variable
Dim strTno as string 'set variable
strCid = txtCustomerID.text 'define variable
strCname = txtCustomerName.text 'define variable
strTno = txtTelephoneNo.text 'define variable
open ("app.path\ & "strCid".txt") for append as #1 'open a file
'named whatever strCid is. I'm unsure of the format I entered
'though. Maybe someone could check it
write #1, "strCid","strCname","strTno" 'write the info to the file.
'note that with the write function, you don't have to enter ""'s or
'the commas, but I do it anyway
Close #1 'closes the file after it's done writing.
Simple as that, though you will need to rearrage the code I'm sure
nugget_head 12-11-2002, 12:51 PM i think you want:
Open (app.path & "\" & strCid & ".txt") For Append As #1
meteo 12-11-2002, 12:54 PM There ya go. Thanks guy!
Thanks for the help everyone. I just went to open my project to try out that code and its saying 'Retained' is an invalid key. The file A:/Greenways........ cant be opened. Whats wrong with it?
thanks for any help
meteo 12-11-2002, 03:25 PM A:\???? A floppy disk? I've never dealt with files for floppies, but I don't think it should be any different. Make sure you are using this:
Open (app.path & "\" & strCid & ".txt") For Append As #1
instead of my "Open" line.
Also, what version are you using?
No I dont mean the code is not working. Im trying to open a project and its im getting an error message but I just remembered Im using VB 5 and I opened it in VB6 at school then saved it and now I cant open it in VB5 anymore. Is there any way I can fix this?
Thanks for any help
G
meteo 12-11-2002, 03:39 PM Hmmmmmm, I don't know. Never come across that problem. So does your project come up at all? If it all loads fine, then I don't think it's a ver conflict, but who knows.
Bucky 12-11-2002, 03:41 PM You can open the files in notepad and then copy and paste the
code from there to the VB5 IDE. I'm not sure if you will be able to
convert your forms back to VB5. Maybe if you copy certain
sections of the code (near the top, the code that is hidden from
the IDE), you may be able to recover them.
Hey is there a way I can change the VB code so I can use it in VB5 again
here is the code
Type=Exe
Form=Greenwaysdata.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS.000\SYSTEM\stdole2.tlb#OLE Automation
Object={00028C01-0000-0000-0000-000000000046}#1.0#0; DBGRID32.OCX
Reference=*\G{00025E01-0000-0000-C000-000000000046}#4.0#0#C:\PROGRAM FILES\COMMON FILES\MICROSOFT SHARED\DAO\DAO350.DLL#Microsoft DAO 3.5 Object Library
Form=Form2.frm
Form=Form3.frm
Form=Form4.frm
IconForm="form1"
Startup="form1"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
CompilationType=-1
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
Thanks for any help
G
oh it does'nt open at all meteo :(
meteo 12-11-2002, 04:07 PM Version conflict.... I have no clue how to re-convert it. I'm sorry guy.
OK no worries I'll try that code out when im in school tommorow.
Thanks for all the help
G
meteo 12-11-2002, 04:23 PM No Prob. The code should work... in all theories. I'm using about 5 procedures that use almost that same exact method. All except for the Open line where you are using the name of the file as the name of the customer. So yeah, it should work fine.
anhmytran 12-11-2002, 08:54 PM 1- Yes, you can open it in Notepad, Word, or WordPerfect,
or even in DOS Edit.
Then copy from "Option Explicit" down. It is the code section.
Obove it, is the documentation and interface design sections.
When you create a new project in VB6, the documentation is
automatically made. You have to make the interface yourself.
The reason is that when the IDE detects the version of VB
that is lower than the current one, it prompts the error message.
However, VB high version may not open VB3 binary format.
YOu should open VB3 binary format in VB3, and Save As text format, so that you can open it in VB4 or higher.
2 - working with floppy disk, the Open command is more easy:
Open ("A:\" & strCid & ".txt") For Append As #1
Hey I just tried the code but nothing in the text box's is being saved. When I open the file the only thing in it is
"strCid","strCname","strTno"
Here is the code
Private Sub Command3_Click()
Dim strCid As String 'set variable
Dim strCname As String 'set variable
Dim strTno As String 'set variable
strCid = TxtCustomerID.Text 'define variable
strCname = txtCustomerName.Text 'define variable
strTno = txtTelephoneNo.Text 'define variable
Open ("A:\" & strCid & ".txt") For Append As #1 'open a file
'named whatever strCid is. I'm unsure of the format I entered
'though. Maybe someone could check it
Write #1, "strCid", "strCname", "strTno" 'write the info to the file.
'note that with the write function, you don't have to enter ""'s or
'the commas, but I do it anyway
Close #1 'closes the file after it's done writing.
End Sub
Thanks for any help
Hey I changed something and its working fine now
Thanks
G
|