Hello i'm trying to make a text editor but i cant find codes for Save button....someone please give me?
I searched on google but no luck (like always)

Edited 4 Years Ago by DyO1: Errors...


You can do it like this:

Imports System.Windows.Forms

public class FileOpenDialogFilter
   public Shared Sub Main
        Dim saveFileDialog1 As System.Windows.Forms.SaveFileDialog

        saveFileDialog1 = New System.Windows.Forms.SaveFileDialog()

        saveFileDialog1.CreatePrompt = True
        saveFileDialog1.FileName = "doc1"

        saveFileDialog1.Filter = "Word (*.doc) |*.doc;*.rtf|(*.txt) |*.txt|(*.*) |*.*"
        If saveFileDialog1.ShowDialog() = DialogResult.OK Then
        End If
   End Sub
End class

'Imports' statements must precede any declarations. C:\Documents and Settings\Administrator\Desktop\555\source\NET\Wtxt\ReAder.vb 71 1 WinEx

no wait...it simply cant save the file...no errors at all

First of all i don't understand why everyone uses IO, i understand no one used it here though.

Anyways. Try this:

Public Class MyForm

    Private Sub MyForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        MySaveFileDialog.Filter = "Text File|*.txt"
    End Sub

    Private Sub MyButton_Click(sender As Object, e As EventArgs) Handles MyButton.Click
        If MySaveFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
            My.Computer.FileSystem.WriteAllText(MySaveFileDialog.FileName, MyTextBox.Text, False)
        End If
    End Sub
End Class

Edited 4 Years Ago by Pride

This article has been dead for over six months. Start a new discussion instead.