|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
IFormatProviderThe I wrote the following Code If Not txtInvoice.Text = "" Then txtInvoice.Text = Convert.ToInt32(txtInvoice.Text()).ToString("000000") End If txtInvoice is a TextBox I use FxCop and it says I should rewrite the code with the following resolution "frmInvoiceDetail.txtInvoice_Leave(Object, EventArgs) :Void makes a call to System.Convert.ToInt32(System.String)that does not explicitly provide an IFormatProvider. This should be replaced with a call to System.Convert.ToInt32( System.String,System.IFormatProvider)." What does it mean that I should Provide an IFormatProvider. What is IFormatProvider How does this work Excuse me for my ignorance Thanks in Advance Regards AQ Que,
This should be enough, I never know what character has to be for those question marks. Cint(txtInvoice.Text)ToString(????????) Maybe you can try it yourself. Show quoteHide quote http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationnumberformatinfoclasstopic.aspI hope this helps,Cor"Que" <aq.maho***@gmail.com> schreef in berichtnews:1158590996.295164.205***@i3g2000cwc.googlegroups.com...> Hi>> The I wrote the following Code>> If Not txtInvoice.Text = "" Then>> txtInvoice.Text => Convert.ToInt32(txtInvoice.Text()).ToString("000000")>> End If>> txtInvoice is a TextBox>> I use FxCop and it says I should rewrite the code with the following> resolution>> "frmInvoiceDetail.txtInvoice_Leave(Object, EventArgs)> :Void makes a call to> System.Convert.ToInt32(System.String)> that does not explicitly provide an IFormatProvider.> This should be replaced with a call to> System.Convert.ToInt32(> System.String,System.IFormatProvider).">> What does it mean that I should Provide an IFormatProvider.>> What is IFormatProvider>> How does this work>> Excuse me for my ignorance>> Thanks in Advance>> Regards> AQ> hi
thanks for the quick reply. i do have that code,as you suggested what i needed to know is how and why should IFormatProvider be implimented and used thanks again. Que An IFormatProvider provides culture specific information regarding how
dates, numbers etc are formatted (since different countries has different rules). The Convert.ToInt32 method you are calling uses an IFormatProvider that matches the settings you have in the regional settings in your control panel. If you're getting input directly from the user this is most likely the behaviour you want (I'm guessing that txtInvoice is a txtbox or similar). If you need to transfer data between systems using different country settings you need to use a common format for it so that each system interprets it the same way (for example; 12.3 is not the same thing in Sweden as it is in the US). That's when you specify a specific IFormatProvider that uses the common rules that you need. In your case it looks like FxCop is a bit overprotective. If you want to get rid of the warning change your line to: Convert.ToInt32(txtInvoice.Text, CultureInfo.CurrentCulture).ToString("000000") This is what the framework does for you internally anyway when you use the version with only one parameter /claes Show quoteHide quote "Que" <aq.maho***@gmail.com> wrote in message news:1158590996.295164.205770@i3g2000cwc.googlegroups.com... > Hi > > The I wrote the following Code > > If Not txtInvoice.Text = "" Then > > txtInvoice.Text = > Convert.ToInt32(txtInvoice.Text()).ToString("000000") > > End If > > txtInvoice is a TextBox > > I use FxCop and it says I should rewrite the code with the following > resolution > > "frmInvoiceDetail.txtInvoice_Leave(Object, EventArgs) > :Void makes a call to > System.Convert.ToInt32(System.String) > that does not explicitly provide an IFormatProvider. > This should be replaced with a call to > System.Convert.ToInt32( > System.String,System.IFormatProvider)." > > What does it mean that I should Provide an IFormatProvider. > > What is IFormatProvider > > How does this work > > Excuse me for my ignorance > > Thanks in Advance > > Regards > AQ >
Newbee - Project with single module.
Change look of button (newbie-VB2005 EE) - filenames in ListBox Method Address from MethodInfo: How do I get it? Threading Service not going to 'Started' No "MS .NET Framework 1.1 Wizards" How can I control positioning of child windows in an MDI form? MDI Form Position Error BC30002 XXXXX Is not defined |
|||||||||||||||||||||||