Results 1 to 3 of 3

Thread: After saving, doesnt work

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    After saving, doesnt work

    In form 2 there is a textbox1

    Button1 is supposed to run the process stated in textbox1
    VB Code:
    1. Process.Start(Form2.Textbox1.text)

    This code is run and the appliction has no errors until:

    Textbox1.text is saved and when form 2 loads again, the saved text is in textbox1 again
    VB Code:
    1. Textchanged
    2. SaveSetting("Startitup", "Textboxes", "Textbox1.Text", TextBox1.Text)

    Form2 Load
    VB Code:
    1. TextBox1.Text = GetSetting("Startitup", "Textboxes", "Textbox1.Text", TextBox1.Text)

    After i input this save code my button does not run the process in textbox1.

    I get this error message:
    InvalidOperationException was Unhandled
    Cannot start process because a file name has not been provided.

    I think the problem is with the saving.
    Coz after the saving code the button doesnt run the process
    Anybody can help me?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: After saving, doesnt work

    I strongly recommend against using SaveSetting and GetSetting anyway. They use the registry, which .NET applications are supposed to avoid doing if possible. You should generally be using the config file or your own XML files to store application settings. TextBox.Text is a dynamic property so it is very simple: http://msdn.microsoft.com/library/de...albasicnet.asp
    VB.NET 2005 adds the My.Settings namespace to make this even easier, although I haven't checked out all the pros and cons just yet.
    Last edited by jmcilhinney; Nov 14th, 2005 at 12:07 AM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Lively Member
    Join Date
    Nov 2005
    Posts
    71

    Re: After saving, doesnt work

    What you could do is try using someting like this

    VB Code:
    1. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    2.         Dim save As New SaveFileDialog
    3.         save.Filter = "A.n.A Files(*.ana)|*.ana"
    4.         save.FilterIndex = 1
    5.         save.InitialDirectory = "C:\"
    6.         save.RestoreDirectory = True
    7.         If save.ShowDialog() = Windows.Forms.DialogResult.OK Then
    8.             Dim nFileNum As Short
    9.             nFileNum = FreeFile()
    10.             FileOpen(nFileNum, save.FileName, OpenMode.Binary, OpenAccess.ReadWrite)
    11.             Dim ****tosave As String
    12.             Dim ****this As Integer
    13.             Dim ***** As Int32
    14.             For ****this = 1 To 150
    15.                 ***** = 0
    16.                 FilePut(nFileNum, *****, ****this)
    17.             Next
    18.             ****tosave = TextBox1.Text
    19.             FilePut(nFileNum, ****tosave, 1)
    20.             ****tosave = ComboBox1.Text
    21.             FilePut(nFileNum, ****tosave, 50)
    22.             ****tosave = ComboBox2.Text
    23.             FilePut(nFileNum, ****tosave, 100)
    24.             FileClose(nFileNum)
    25.             MsgBox("Done!", MsgBoxStyle.Exclamation, "")
    26.         End If
    27.     End Sub

    and then to open the file

    VB Code:
    1. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    2.         Dim open As New OpenFileDialog
    3.         open.Filter = "A.n.A Files(*.ana)|*.ana"
    4.         open.FilterIndex = 1
    5.         open.InitialDirectory = "C:\"
    6.         open.RestoreDirectory = True
    7.         If open.ShowDialog() = Windows.Forms.DialogResult.OK Then
    8.             Dim nFileNum As Short
    9.             nFileNum = FreeFile()
    10.             FileOpen(nFileNum, open.FileName, OpenMode.Binary, OpenAccess.ReadWrite)
    11.             Dim ****tosave As String
    12.             ****tosave = Space(50)
    13.             FileGet(nFileNum, ****tosave, 1)
    14.             TextBox1.Text = ****tosave
    15.             FileGet(nFileNum, ****tosave, 50)
    16.             ComboBox1.Text = ****tosave
    17.             FileGet(nFileNum, ****tosave, 100)
    18.             ComboBox2.Text = ****tosave
    19.  
    20.  
    21.         End If
    22.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width