none
Too many arguments to 'Public ReadOnly Default Property Chars....' RRS feed

  • Question

  • One of my ASP.NET websites makes use of the CultureInfo class to format currency values and normally this works fine. However, some new code is causing some unexpected problems and I am wondering if it is a LINQ To SQL issue. In the code sample shown below, txtBox1 correctly displays £99.00 while the line that specifies a value for txtBox2 generates the following error,

    Too many arguments to 'Public ReadOnly Default Property Chars(index As Integer) As Char'.

    The key difference in the txtBox2 value is that it is derived from a SQL Server database reference using LINQ To SQL (CurrentUKFees.Print1). The relevant database value is the integer 8 and I was expecting txtBox2 to show £8.00. If I delete the CultureInfo code then txtBox2 correctly shows the value '8' without any currency formatting.

    Any guidance would be much appreciated. I'm probably making a very simple mistake....

    David

     

    Dim CurrentUKFees = (From fees In myDBC.UKFees Where fees.CompID = ConfigurationManager.AppSettings("CurrCompID"Select fees).SingleOrDefault
    Dim GBCulture As New CultureInfo("en-GB")
    txtBox1.Text = 99.ToString("C", GBCulture)

       txtBox2.Text = CurrentUKFees.Print1.ToString("C", GBCulture)

    Tuesday, November 8, 2011 1:54 PM

Answers

  • did you try:

    CurrentUKFees.ToString.Format("C",GBCulture)
    


    Trying  txtBox2.Text = CurrentUKFees.Print1.ToString.Format("C", GBCulture) simply caused a different error message, i.e.

    • Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

    However, I have stumbled across a solution. The following code appears to work without any problem, though I don't really know why. I don't normally find that specifying 'value' is required in VB.NET code.

                     txtBox2.Text = CurrentUKFees.Print1.Value.ToString("C", GBCulture)

     

    • Marked as answer by haggis999 Tuesday, November 8, 2011 4:10 PM
    Tuesday, November 8, 2011 4:00 PM

All replies

  • did you try:

    CurrentUKFees.ToString.Format("C",GBCulture)
    
    Tuesday, November 8, 2011 2:10 PM
  • did you try:

    CurrentUKFees.ToString.Format("C",GBCulture)
    


    Trying  txtBox2.Text = CurrentUKFees.Print1.ToString.Format("C", GBCulture) simply caused a different error message, i.e.

    • Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

    However, I have stumbled across a solution. The following code appears to work without any problem, though I don't really know why. I don't normally find that specifying 'value' is required in VB.NET code.

                     txtBox2.Text = CurrentUKFees.Print1.Value.ToString("C", GBCulture)

     

    • Marked as answer by haggis999 Tuesday, November 8, 2011 4:10 PM
    Tuesday, November 8, 2011 4:00 PM