VS 2005 : User Settings Metric/Imperial XMLserialize?
Apr 1, 2009
I am having a bit of an issue and would like some opinions. I have a settings class that I use in my program that gets passed around to various pieces of the program. When the program exits, the settings class is serialized out to an xml file. When the program starts the settings class is serialized back from the xml file.If the program doesn't find an existing xml file, the defaults in the class are used and a new xml file is created when the program exits.This all works well. Here is a trimmed down version of my settings class:
Public NotInheritable Class UserSettings
Private _Length As Double = 10 'feet
Private _Name As String = "Inert Material"
[code]....
The problem that I am having is that if the program units are metric, then the default values are always converted in the constructor and the xml serializer then stuffs the values that exist in the configuration (over writing the converted default value which is what I want) into the proper properties. The reason for this behavior is to make sure that that new properties that don't exist in the xml file have a proper default value when metric units are required.
It seems wasteful to convert all of the default values every time when working with metric units? Is there a better way to do this? My full class has currently about 15 default values that need to be converted to metric equivalents. Ideally I would only like to convert values that haven't come from the xml file.
When the program exits, the settings class is serialized out to an xml file. When the program starts the settings class is serialized back from the xml file.If the program doesn't find an existing xml file, the defaults in the class are used and a new xml file is created when the program exits.This all works well. Here is a trimmed down version of my settings class:
Public NotInheritable Class UserSettings Private _Length As Double = 10 'feet Private _Name As String = "Inert Material"
I am making a program that calculates various results with variables entered by the user. What I am trying to do is incorporate a function that will allow the user to switch from metric to imperial easily but only when the ok button is pressed. Now I got all the coding done for the metric and everything is working fine. My problem is when I use the radiobuttons to switch the entered variable in the text box to the desired unit it gives me a 0 or a random number in the textbox...
I also have labels indicating each variables unit which I easily managed to change with the text box using this code. : 'Change Labels to Metric lblMDegreeC.Text = "Degree C" lblMDegreeC2.Text = "Degree C" lblMmm.Text = "mm" lblMmm1.Text = "mm" lblMmm2.Text = "mm" lblMm.Text = "m" lblMm2.Text = "m" lblMm3.Text = "m" lblMDegreeC3.Text = "Degree C"
I created all the coding to convert the metric variables to imperial. My problem is changing the textbox text when the user switches the units during run time. The labels change without a problem but the textbox never works. I have attached the coding for the file.
I noticed that the application settings (user.config) are stored in my AppData directory which is names quite oddly: C:UsersclarkgriswaldAppDataLocalCompanyMyApp10.exe_Url_zwsqzsjtunwuxfkklwa3fcjple4hufb01.0.0. 0 Is there anyway to adjust that path? The main reason is that when I release a new version, I want to copy the old settings into the new application's directory, and with a name like that, it's not really feasible.
I am rewritting my application to conform to ms standards. We used to save all settings to registry for user settings, servername, size and locations.so we are now saving them into My.Settings app.config the only problem is that each time there is an update clickonce will isntall the newupdate but now all settings are loist and user has to save everything all over again..
I am trying to follow the book here but it seems i keep getting stuck somewhere. registry has worked fine for years but i understand we must move on, but if stuff like this happens then i just wasted a long time converting all code to conform for it to not work..
1. I can't find the file which reflects changes to user settings. This might be because I just can't find it (I can see a bunch of user.config files but they are all empty - weird!), or...
2. I'm not actually saving them when I think I am.
Regarding 2. - do I need to invoke
Is this all I need? And if so, why are my user.configs empty?
I just wondered if you can or can't save arrays using the settings system object. There seems to be no way of entering it at designtime. It seems implied you cannot create new user settings.subobjects at runtime. I'm looking to find the easiest way to save a populated array of PictureBox's. If the only way is a self/custom made/managed .ini file then I need to know so i can start on that but I was hoping to use some of all this phaff in the new frameworks usefully.
The following (abysmal) code demonstrates how standard serialize/de-serialize in VB loses the CR when on de-serialize. This can be overcome by applying 'XmlAttribute(DataType:="string")' to Description. Why does it do this? I would like to fix this without applying a 'LF' -> 'CR''LF' in every affected class. This is fixing a bug in existing XML files generated without the XmlAttribute!
how to reset user settings in My.Settings to the default value, because when i checked if the user settings works i have altered the settings so now i want the settings to go back to default, because i am going to distribute the software.
I am attempting to create an application in an attempt so it could be run as the user and preserve individual settings, by this what i am trying to achieve is when the application is installed, it is installed once but each user has their own settings saved within their own profile - a bit like Office applications. How could i start with this?
I'm trying to save a collection of key/value settings in my application's "user settings" (they're column widths), but while I see no errors, when I run the code (in the IDE) my collection in "My.Settings" is always nothing at startup. I do a "My.Settings.Save" when the application exits, and barring the "serializers not found" errors in the IDE, no other errors occur. When I run my application as an exe, it behaves the same way..
No not of the Simple Object Access Protocol variety, but Soap It seams that Imperial Leather is the .NET developers soap of choice. This means however that we will all smell the same, and will make detecting a fellow developer out in the wild a little more difficult, since you cant smell your own scent. May i also suggest that PEARS Soap is not only far more visually appealing than Imperial Leather, but it actually smells much nicer too. Plus the Queen buys it as well, so just think on that the Royal bottom gets washed with this stuff:what says the masses?
My program needs to convert the variables users enter in textboxes from metric to imperial and vice versa so the user can switch units at any time during run time and have the values in the textboxes display the correct value. The problem is that for example if the user initially enters all his values in metric when converting I will be displaying the rounded value of the imperial value. If the user initially enters his values in imperial, when converting I will be displaying the rounded value of the metric value.
But the problem occurs when then user switches back to the original units all the values go to 0 because in the coding for my radio button I set the txtboxes to the rounded xxx value. How to code the radiobuttons to detect what unit was initially selected to set the right values. What I tried doing was set a counter on the radio buttons to determine which one has been pressed more often... but there has got to be a better way to do this..
Imperial Radio button: Private Sub optImperial_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optImperial.CheckedChanged 'Change Labels to Imperial lblMDegreeC.Text = "Degree F" lblMDegreeC2.Text = "Degree F" [Code] .....
Write a program to convert a U.S. Customary System length in miles, yards, feet and inches to a. Metric System length in kilometers, meters, and centimeters.
I found this same project on these boards already however I received an error and was seeing if someone could see what I did wrong.
My error message is: 'lstResult' is not declared
Public Class lengthConversion Private Sub convertBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles convertBtn.Click
Declare constants for all numeric values in the two formula above. The variable used to represent the number of meters and the numeric constant 39.37 must be declared as the data type double. the constants and data types in the first formula should be declared as integers. Convert the Total Inches in the second formula to a Double data type before using it in the calculation. Set Option Strict to on in your code. (Hint: After the number of meters has been determined, the maximum number of kilometers can be computed from Kilometers = Meters/1,000. Next, the remaining meters can be determined from: Remaining Meters = Meters - 1,000 * Kilometers. The number fo integer meters in Remaining Meters then can be determined from: Integer Meters = Convert.ToInt32(Remaining Meters). Continue with the same technique to compute the number of centimeters.)
I have an application that uses user settings and I have a button that gets a value (long) and writes this in a textbox I then have a setting called StoredKey with the data type of long I then pass this to the setting like this:my.settings.StoredKey=cLng(textbox1.text)this all works well in debug, but when I deploy my application and try to store the value in my.settings.StoredKey the value never gets written in!by deploy I mean packaging the exe in a setup and deployment project type and performing the wizard install to c:program files.[code]
So, I've created a form that allows for the user to save his or her settings after closing it. When using Visual Basics to run the program, there is no problem and it works wonders.Here is the problem.When I run the program not in Visual Basics, when I go to open the form, it fails. At first, it was because I didn't update the configuration file to include the new settings. Which was dumb, of course, but I updated the file and made sure to put it with the program.
how to convert a metric unit to standard. I will be converting Feet/Inches to Meters/Centimeters and vise versa as well as pounds/ounces to kilograms/grams and vise versa. I can input the values into my Textbox to where it reads " x'y" ," however, when I go to code the Convert button (the same button has to be used for all conversions) how to separate out the text and then perform the conversion.
ive got to create a BMI calculator using metric units, when i enter my data, it doesnt work (i put in 1.5m and 90kg but the answer comes out at 3, and in clearly not anorexic heres what ive got at the moment
Dim BMIResults As New frmBMIResults Dim Answer As Integer Dim BMIAnswer As Integer Answer = CType(tbHeight.Text, Integer) * 2 BMIAnswer = CType(tbWeight.Text, Integer) Mod Answer 'BMIResults.Show() 'Me.Hide()
I'm trying to make a metric to kilogram converter and I am having trouble starting it out. With my Answer label being txtAnswer and the Inches button being btnInches, I have ran into snags with trying to get it formulate the 37, 370 into 1 Kilometer I believe that it needs to be a sring but I am stuck.
i am new to VB and am trying to make a metric to imoerial unit converter in VB 2008. I have created a form with 2 list box's with MM, CM, KM etc ....... and the other Inches Miles etc I have added 2lables with convert from and convert to and also 2 blank text box's the first one to choose the number i would like to convert and another to show the converted unit, I have also added a convert button.I am really struggling to find the correct code to make this work.
I have a NumericUpDown Control on a form. In the Application Settings / Properties Binding, for the value parameter, i can't select my USER setting called : Heures (Integer / User).
[Code]...
But it's not saved.No problem for other settings (String / User). But i don't understand why the settings (Integer / User) are not saved.
I have a Boolean, user scoped setting. I access it through a referenced class library, called Settings. This class library has a Module with properties:
[Code]...
While the code is running this works. But after a restart of the application the new value is not persisted.
I'd like to know if there's a better way to read/write various user settings to disk. My program loads up a bunch of settings during load but also during execution from a few different forms, encrypted string values, boolean values, different types. The code seems to work okay but I have a feeling it's just not the best way to be doing this. Some of the settings are encrypted strings that have to be decrypted/encrypted so the code to read/write the text file is a bit different on some items. The data read from disk usually goes to a public string, a textbox, or a up/down type control. Below is about 1/10th of the settings that get loaded/written at various times. Anyone have a better way that might be more efficient that I should look at?
This has 2 ComboBoxes, 2 Buttons, a FontDialog & a RichTextBox.The code I used :
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.AddRange(New String() {"London: 51N30, 00W07", "Paris: 45N38,5E44", "Colombo-Sri Lanka: 06N55,79E50", "Chennai-India: 13N05,80E17", "Sydney-Aus: 33S53, 151E13", "Toronto-Canada: 43N40,79W25", "New York-USA: 40N42,74W00"})
So, I've created a form that allows for the user to save his or her settings after closing it. When using Visual Basics to run the program, there is no problem and it works wonders. When I run the program not in Visual Basics, when I go to open the form, it fails. At first, it was because I didn't update the configuration file to include the new settings. Which was dumb, of course, but I updated the file and made sure to put it with the program.
However, when I opened the program again, it failed. So, I tried putting an error message in the form so I know why it failed. This time, it would come back saying "Error Occurred. The Following Error Occurred:" and that is it. No details at all why it was having any problems reading my new user settings. Once again, the user settings work fine in visual studios. It has the updated configuration file in the same place it is.