Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2010 > Visual Basic 2010 General Discussion
| Search | Today's Posts | Mark Forums Read
Visual Basic 2010 General Discussion For any discussions about Visual Basic 2010 topics which aren't related to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2010 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 19th, 2011, 11:58 AM
Registered User
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question making a SAVE AS to save text boxes in a windows form VB2010 Express

i am making a program that has 5 text boxes (TextBox1-TextBox5) and i am wanting to be able to click a save button and it pop up a SaveFileDialog asking me where i want to save the file and under what name. (Kart Setup 7-9-2011) then at a later date be able to fill in the text boxes and push the save button and it ask me again where to save it, so that i am making a new text file for each time i push save. Then if need be i want to be able to push a OpenFileDialog button and open the text files placing the info from the TextBox1 back in TextBox1 and so forth down the line of text boxes. I am new to visual basic i am in dear need of some help on this.
Thank you all for any help
  #2 (permalink)  
Old July 28th, 2011, 08:36 AM
Authorized User
Points: 319, Level: 6
Points: 319, Level: 6 Points: 319, Level: 6 Points: 319, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: May 2010
Location: MIssouri
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default SaveFileDialog

Open A New Project, Locate The Dialog tab in the toolbox. Drag OpenFileDialog & SaveFileDialog OnTo The Form. Copy & Paste text Over all text in Form1.vb. PLace 5 Text boxes on the form. Then PLace 2 Buttons on the Form

When you run the Program it should work as advertised.. if not repost any other questions.

 Imports System.IO

Public Class Form1
    Dim ires As Integer = 0
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        ires = InputBox("Save Which TextBox " & vbCrLf & " Enter A NUmber Between 1 and 6... 6 Being All Boxes", " Enter A Number 1-6")
        If ires < 1 Or ires > 6 Then Exit Sub

        If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Dim myStream As New StreamWriter(SaveFileDialog1.FileName, True)
            Select Case ResizeRedraw
                Case 1
                Case 2
                Case 3
                Case 4
                Case 5
                Case 6
                    MsgBox(" Place a Do Loop Code Here To Loop 6 Times And Either Prompt 5 times FOr a Filename Or INcerment File Name For Each TextBox")

            End Select


        End If

    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

        If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

            Dim myReader As New StreamReader(OpenFileDialog1.FileName)
            TextBox1.Text = myReader.ReadToEnd

        End If

    End Sub

    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        TextBox1.Multiline = True
        TextBox1.Size = New Size(500, 500)

        TextBox2.Multiline = True
        TextBox2.Size = New Size(500, 500)
        TextBox3.Multiline = True
        TextBox3.Size = New Size(500, 500)
        TextBox4.Multiline = True
        TextBox4.Size = New Size(500, 500)
        TextBox5.Multiline = True
        TextBox5.Size = New Size(500, 500)
    End Sub
End Class
The Magic is in the top line " Imports System.IO" Which Sets the reference to The Input/Output Streams.

Just be sure to space the textboxes plenty far apart!

Good Luck

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to save form Omomani Infopath 0 January 3rd, 2008 06:15 AM
Save report to Windows 2003 Server Bhavin Crystal Reports 0 March 14th, 2005 02:39 PM
How do you save a form as is? flyingfox VB.NET 1 May 21st, 2004 03:47 PM
how to save text with format?? 6cet6 ASP.NET 1.0 and 1.1 Basics 4 November 20th, 2003 06:49 AM
Save Form as Text File cooky4 VB How-To 1 September 12th, 2003 01:40 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.