Member Avatar for DyO1

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)

Recommended Answers

All 6 Replies


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
Member Avatar for DyO1

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

Member Avatar for DyO1

no simply cant save the 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
Member Avatar for DyO1

Thank you!

No problem! :D

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.