Trying to get values from last formclosing
Trying to get values from last formclosing
Trying to get values from last formclosing
Trying to get values from last formclosing
Trying to get values from last formclosing
Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing
Trying to get values from last formclosing Trying to get values from last formclosing
Trying to get values from last formclosing
Go Back  Xtreme Visual Basic Talk > > > Trying to get values from last formclosing


Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2009, 03:47 PM
andy38 andy38 is offline
Regular
 
Join Date: Sep 2005
Posts: 52
Default Trying to get values from last formclosing


H1, Using VB Net (2005, Access (2003) in Windows Forms, I have this app that has many forms and one of those is a Setup Option Form, like the title say it is for setting up different options i.e tax option single tax or 2 taxes (Gst and Pst) tax value, ect. I have setup 4 of those parameters in my Settings tab as is: OptionShown, Boolean, User, and False. AppSettings1, Boolean, User, True. AppSettings2, String, User, . AppSettings3, String, User, . AppSettings4, Boolean, User, True. As you see I did not put values for AppSettings2 and 3 I am trying to put these values thru my textboxes on my SetupOption form because those settings can be change, also those changes are save on SetupOption formclosing. Since this Setup Option Form is not the main form, I am trying to read the values that were in those textboxes at form closing so to be able to put them into variables in main form
Like this: Gst=Val(F5.txt5GstTax.Text) same for Pst=Val(F5.txt5PstTax.Text) I get values only when SetupOption Form has been open on that application run, if the app is close and restart then there are no values for Gst and Pst. Do I need to have a value in the value column of the Setting tab or can it be a variable if so plz show me how to do it .Thank you in advance
Reply With Quote
  #2  
Old 06-22-2009, 04:40 PM
Roger_Wgnr's Avatar
Roger_Wgnr Roger_Wgnr is offline
CodeASaurus Hex

Forum Leader
* Expert *
 
Join Date: Jul 2006
Location: San Antonio TX
Posts: 2,427
Default

Assuming that TextBox2 contains the info to save in AppSettings2.
1) In the form Closing event for your settings form
Code:
My.Settings.AppSettings2 = TextBox2.Text
2) In the Form Load Event for your settings form
Code:
TextBox2.Text = My.Settings.AppSettings2
Also you need to be saving the other settings also or they will always be the default values.

Another alternative is to use the Applications settings Property and Bind the Setting to the Text Property of the Textbox.
__________________
Code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
The user is a peripheral that types when you issue a read request. ~Peter Williams
MSDN Visual Basic .NET General FAQ

Last edited by Roger_Wgnr; 06-22-2009 at 04:47 PM.
Reply With Quote
  #3  
Old 06-22-2009, 06:56 PM
andy38 andy38 is offline
Regular
 
Join Date: Sep 2005
Posts: 52
Default

Hi,Thank you for your quick response,I do not quite understand "Assuming that TextBox2 contains the info to save in AppSettings2." does that mean I have to declare in Settings tab "Value Column" txt5GstTax, because as as this moment this "Value Column" is empty. SetupOption Form is not the main
program but this is where formLoad and formClosing are see bellow
code
Private Sub frmSetupOption_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
' Set RadioButton and textboxes for the application
Me.Rad5btn4.Checked = My.Settings.AppSetting1
Me.txt5GstTax.Text = My.Settings.AppSetting2
Me.txt5PstTax.Text = My.Settings.AppSetting3
Me.chk5TaxLabour.Checked = My.Settings.AppSetting4
My.Settings.OptionShown = True
Gst = Val(txt5GstTax.Text)
Pst = Val(txt5PstTax.Text)
chk5TaxLabour.Checked = True
chk5ReProTax.Enabled = False
End Sub
Private Sub frmSetupOption_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Try
My.Settings.AppSetting1 = Me.Rad5btn4.Checked
My.Settings.AppSetting2 = Me.txt5GstTax.Text
My.Settings.AppSetting3 = Me.txt5PstTax.Text
My.Settings.AppSetting4 = Me.chk5TaxLabour.Checked
'My.Settings.MainFormSize = Me.Size
'Save the user settings so next time the window will be the same size and location
My.Settings.Save()
MsgBox("Your settings were saved successfully.", MsgBoxStyle.OkOnly, "Save...")
Catch ex As Exception
MsgBox("There was a problem saving your settings.", MsgBoxStyle.Critical, "Save Error...")
End Try
End Sub
Like I said in my first post it only get values if I load SetupOption Form.
Reply With Quote
  #4  
Old 06-22-2009, 10:39 PM
Roger_Wgnr's Avatar
Roger_Wgnr Roger_Wgnr is offline
CodeASaurus Hex

Forum Leader
* Expert *
 
Join Date: Jul 2006
Location: San Antonio TX
Posts: 2,427
Default

To use the appSettings in another form you will need to specifically call it from that form or load it in the form load of the main form to a global variable.
One othe option is to call FrmSetupOption.Load in your main form Load.
This will load the form making the variables accessable but will not display the form. If you do this you must make sure to call FrmSetupOption.Unload before you close the program. This can be easily done by looping through all forms and unloading them prior to closing the main program.
__________________
Code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
The user is a peripheral that types when you issue a read request. ~Peter Williams
MSDN Visual Basic .NET General FAQ
Reply With Quote
  #5  
Old 06-23-2009, 11:04 AM
andy38 andy38 is offline
Regular
 
Join Date: Sep 2005
Posts: 52
Default

Hi again,Thank you for your quick response you have mentioned many solutions, which would be the best one and could you elaborate on the global varriable. I have try to use Call from Main form could not get it to work, in my SetupOPtion Form what I did Was to create a Private frmSetupOption_Load(), and then call it from Private Sub
frmSetupOption_Load(ByVal sender as System.Object, ByVal e As Systen.EventArgs) Handles Me.Load then in my main form load I use this Call F5.frmSetupOption_Load iget this error " Overload resolution failed because no frmSetupOption_Load is accessible."
and
Reply With Quote
  #6  
Old 06-28-2009, 07:44 PM
andy38 andy38 is offline
Regular
 
Join Date: Sep 2005
Posts: 52
Default

Hello,could someome show me how this is done using: To use the appSettings in another form you will need to specifically call it from that form or load it in the form load of the main form to a global variable. One othe option is to call FrmSetupOption.Load in your main form Load. This will load the form making the variables accessable but will not display the form. Thank you in advance
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Trying to get values from last formclosing
Trying to get values from last formclosing
Trying to get values from last formclosing Trying to get values from last formclosing
Trying to get values from last formclosing
Trying to get values from last formclosing
Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing Trying to get values from last formclosing
Trying to get values from last formclosing
Trying to get values from last formclosing
 
Trying to get values from last formclosing
Trying to get values from last formclosing
 
-->