Hello, i am currently developing a new OpenSource project.
I will release it to the public this week. :-)

Let's get to my question(s) then:

  • I have a Rich Text Box, and i want to save that text into a default extension.
  • I want the default name to be found in the textbox, E.g: Hello my name is Zack (The file would appear as default name Zack on the Save File Dialog, but if the name was Richards, it would appear Richards instead).
  • Also, the Save File Dialog should open a default folder. (.../Saved)

I lack knowledge in saving files on VB.NET, any help would be greatly appreciated and a great boost on my project.

Add a savefiledialog (here sfd) to your form
the following code you add into your save click event

With sfd
            .FileName = stri.Replace("Hello my name is ", "") & ".rtf"
            .InitialDirectory = My.Application.Info.DirectoryPath & "/Saved/"
        End With

and the next code you just add to your code

Private Sub sfd_FileOk(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles sfd.FileOk
        RichTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.RichText)
    End Sub

very good

Thank you, you really helped me.
Will be sure to stay here at DaniWeb.

What do you mean with "stri", it says that it is not declared.
I am using Visual Basic 2008

stri can be replaced by Textbox1.Text

Thanks, this is almost solved.
The problem is:

  • if there is a large text in the textbox, i would like to delete it from the filename, only getting the "my name is Zack" part, therefore making it possible to write a whole text and it finds "my name is Zack" somewhere, and gets Zack as filename (Zack has example, could be Richards or anything else.

Thats pretty hard if the text is always different. A simple solution would be that you force the user to write their name into a sepearate textbox so you can use that as the file name.
If you want to stick to the solution you already have then it will be pretty hard because you never know where the name is and users normally never stick to the syntax, so you cant trust them that they will always write "hello my name is blabla"

This would be used for a Java Compiler.
Which always has the "public class Scriptname" part, which "Scriptname" has to be the name of the file.
Thank you for your help, but is it anyway to do this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.