473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Create a File Extension

I am looking to create a file extension that I can use with my first VB project. I want it to save text like a .txt file but I want it to be a custom file extension like .bttf. I also need to know how to save the text in the textbox to that file in my program. If this is possible I would love to know how.

Thanks
May 2 '07 #1
8 4018
ansumansahu
149 100+
I am looking to create a file extension that I can use with my first VB project. I want it to save text like a .txt file but I want it to be a custom file extension like .bttf. I also need to know how to save the text in the textbox to that file in my program. If this is possible I would love to know how.

Thanks

You can infact use any extension that you like whenh you save the file. Just for example have .txt file created on your machine. Open this file in notepad and enter some texts and save it.Then manually go and change the extension of the file from .txt to .bttf. Then again try to open the file. It will ask you in which program to open it. Use notepad once again and see whats happening.
Regarding saving the text from the text box it should be the same procedure that you would have followed for writing the text to a text file.

good luck
-ansuman sahu
May 2 '07 #2
I am looking to create a file extension that I can use with my first VB project. I want it to save text like a .txt file but I want it to be a custom file extension like .bttf. I also need to know how to save the text in the textbox to that file in my program. If this is possible I would love to know how.

Thanks
u cant save text which is in textbox for dat use rich text box
May 2 '07 #3
Killer42
8,435 Expert 8TB
u cant save text which is in textbox for dat use rich text box
If I might elaborate slightly, I think what ChillUmesh is trying to say is that the textbox control doesn't include a method to save the text, as is the case for the RichTextBox control.

That does not mean that you can't save the text, of course - it simply means that your code must do the file-access work itself rather than relying on the control to handle it. This is not difficult.
May 2 '07 #4
You can infact use any extension that you like whenh you save the file. Just for example have .txt file created on your machine. Open this file in notepad and enter some texts and save it.Then manually go and change the extension of the file from .txt to .bttf. Then again try to open the file. It will ask you in which program to open it. Use notepad once again and see whats happening.
Regarding saving the text from the text box it should be the same procedure that you would have followed for writing the text to a text file.

good luck
-ansuman sahu
I understand this, but I want it to open with my program and not have to choose a program to open with every time you open it. Can I do this?
May 2 '07 #5
u cant save text which is in textbox for dat use rich text box
I have a rich textbox, how do I save the data/text in the textbox?
May 2 '07 #6
Killer42
8,435 Expert 8TB
I understand this, but I want it to open with my program and not have to choose a program to open with every time you open it. Can I do this?
If you want this to happen on other computers, you'll have to set up an installation procedure to register the file extension. Not sure how you do that. But on your own PC, when it asks, just tick the "always use this program" option so it won't ask again next time.
May 3 '07 #7
Dököll
2,364 Expert 2GB
I have a rich textbox, how do I save the data/text in the textbox?
You must truly hate your computer:-)

I think I got an idea that might work. We'll start by helping you save to .txt and we'll discuss the rest. Everyone please throw your hat, I am not sure hw far I can go with this:

(1) When you load text to say 'Text1.Text', have it saved on your machine as .txt

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub STORE_ME_Click()
  3.  
  4. Open App.Path + "\SaveThisFile.txt" For Append As #1
  5.  
  6.                 Write #1, , Text1.Text
  7.  
  8.                 Close #1
  9.  
  10. Text1.Text = ""
  11.  
  12. End Sub
  13.  
  14.  
Have your Form_Load look for this text in that file. When file loads back to your application:

(2) Tell Form_Load to add it in Text1.Text

Form_Load Code

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub RETURN_ME_Click()
  3.  
  4. Dim FileLine As String
  5.  
  6. Open App.Path + "\SaveThisFile.txt" For Input As #1
  7.  
  8.                     Do While Not EOF(1)                                                         
  9.                             Input #1, FileLine
  10.                             If FileLine$ <> "" Then
  11.                             Text1.Text = FileLine
  12.                             End If
  13.                     Loop
  14.                     Close #1
  15.  
  16.  
  17. End Sub
  18.  
  19.  
Now if that works, and you can see data in Text1.Text. You can try saving and retrieving as bttf. Here's the problem, you can modify the code to save as the file extension of your choice, but Windows does not seem to know how to open the file as bttf. Unless you tell VB:

(3) SaveThisFile.txt = SaveThisFile.bttf, therefore to load the file

Hence:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Open App.Path + "\SaveThisFile.bttf" For Append As #1
  3.  
  4.  

Form_Load (Step 2)


Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub RETURN_ME_Click()
  3.  
  4. Dim FileLine As String
  5.  
  6. Open App.Path + "\SaveThisFile.bttf" For Input As #1
  7.  
  8. SaveThisFile.bttf = SaveThisFile.txt
  9.  
  10.                     Do While Not EOF(1)                                                         
  11.                             Input #1, FileLine
  12.                             If FileLine$ <> "" Then
  13.                             Text1.Text = FileLine
  14.                             End If
  15.                     Loop
  16.                     Close #1
  17.  
  18.  
  19. End Sub
  20.  
  21.  
I am not sure how this makes logical sense or whether, it can work, VB is not installed here cannot run it. Give me sometime to look through it again on my notebook. Please throw your hat in, Scripts Members.

Dököll
May 6 '07 #8
Try this:
Use the Form1.Load command to create a file type/association. This shows how to create a file type that looks like *.hello:

My.Computer.Registry.ClassesRoot.CreateSubKey(".He llo").SetValue("","Hello",Microsoft.Win32.Registry ValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Hel lo\shell\open\command").SetValue("", Application.ExecutablePath & " ""%l"" ", Microsoft.Win32.RegistryValueKind.String)

Now add the rich text box object to your form along with a Save file Dialog, and an Open File dialog. Change the filter on both dialogs to "Hello Files (*.hello)|*.hello". Now the user can open and save hello files, and your program will launch when that file type is clicked.
Good luck!
Hope this helped!
Oct 16 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
7
by: Martin | last post by:
I have a situation where I'm displaying some information in a table on a web page. I've given the user the ability to make several different "queries" and show different sub-sets of the data. I...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
4
by: Daniel Sitima | last post by:
I cannot to create project in Windows Server 2003 with Visual Studio .NET 2003; The error returned was: The default Web access mode for this project is set to file share, but the project...
4
by: jaredea | last post by:
I have the following setup: SBS 2003 Server Windows 2003 Enterprise Server (setup as an Application Server) Windows XP Pro Desktop Both the Application server and desktop have Visual Studio...
1
by: dekel | last post by:
I'm trying to find the way to create and debug dumpfile of dotnet application. Any recommendation of articles, tools for creating dump file + debug it are appreciated. The documentation I...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
7
by: Danny | last post by:
Hello: I would like to develop a browser extension, or whatever such a thing is classified as, that would allow a user of IE6, and possibly IE7, to switch between a live and development page. ...
0
ADezii
by: ADezii | last post by:
Rather than using CurrentProject.Connection or entering your own Connection information, ADO supports storing Connection information in an external file called a Data Link File (which normally has a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.