|
-
Nov 13th, 2005, 11:26 PM
#1
Thread Starter
Junior Member
After saving, doesnt work
In form 2 there is a textbox1
Button1 is supposed to run the process stated in textbox1
VB Code:
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:
Textchanged
SaveSetting("Startitup", "Textboxes", "Textbox1.Text", TextBox1.Text)
Form2 Load
VB Code:
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?
-
Nov 13th, 2005, 11:37 PM
#2
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.
-
Nov 14th, 2005, 12:03 AM
#3
Lively Member
Re: After saving, doesnt work
What you could do is try using someting like this
VB Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim save As New SaveFileDialog
save.Filter = "A.n.A Files(*.ana)|*.ana"
save.FilterIndex = 1
save.InitialDirectory = "C:\"
save.RestoreDirectory = True
If save.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim nFileNum As Short
nFileNum = FreeFile()
FileOpen(nFileNum, save.FileName, OpenMode.Binary, OpenAccess.ReadWrite)
Dim ****tosave As String
Dim ****this As Integer
Dim ***** As Int32
For ****this = 1 To 150
***** = 0
FilePut(nFileNum, *****, ****this)
Next
****tosave = TextBox1.Text
FilePut(nFileNum, ****tosave, 1)
****tosave = ComboBox1.Text
FilePut(nFileNum, ****tosave, 50)
****tosave = ComboBox2.Text
FilePut(nFileNum, ****tosave, 100)
FileClose(nFileNum)
MsgBox("Done!", MsgBoxStyle.Exclamation, "")
End If
End Sub
and then to open the file
VB Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim open As New OpenFileDialog
open.Filter = "A.n.A Files(*.ana)|*.ana"
open.FilterIndex = 1
open.InitialDirectory = "C:\"
open.RestoreDirectory = True
If open.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim nFileNum As Short
nFileNum = FreeFile()
FileOpen(nFileNum, open.FileName, OpenMode.Binary, OpenAccess.ReadWrite)
Dim ****tosave As String
****tosave = Space(50)
FileGet(nFileNum, ****tosave, 1)
TextBox1.Text = ****tosave
FileGet(nFileNum, ****tosave, 50)
ComboBox1.Text = ****tosave
FileGet(nFileNum, ****tosave, 100)
ComboBox2.Text = ****tosave
End If
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|