Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 25th, 2006, 09:26 AM
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET 1.1 to 2.0 FormatCurrency Problem

I have a site that uses the FormatCurrency method in ASP.NET 1.1 in the following way:

strTax = FormatCurrency(strTax)

We just installed ASP.NET 2.0 on this server, and I now receive the following error message:

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 323: strTax = Left(strTax, Len(strTax) - 6) & "," & Right(strTax, 6)
Line 324: End If
Line 325: strTax = FormatCurrency(strTax) '<<---Problem code
Line 326: 'Format special tax
Line 327: If Len(strSpec_tax) > 2 Then

So if anyone can help me to change my code so that the FormatCurrency method is used in the proper way for ASP.NET 2.0, that would be great. Thanks for any help.

KWilliams
 
Old October 25th, 2006, 10:28 AM
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've solved the problem by adding the following if statement around the problem code:

If strTax <> 0 Then
   If Len(strTax) > 2 Then
      strTax = Left(strTax, Len(strTax) - 2) & "." & Right(strTax, 2)
   End If
   If Len(strTax) > 6 Then
      strTax = Left(strTax, Len(strTax) - 6) & "," & Right(strTax, 6)
   End If
End If
strTax = FormatCurrency(strTax)

The original code couldn't handle a zero value, so this solved the problem. Thanks anyway.:)

KWilliams




Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom HTTP 404 Problem w/ASP to ASP.NET kwilliams ASP.NET 2.0 Professional 7 November 26th, 2007 04:17 PM
Problem Converting C# to VB.NET in ASP.NET kwilliams ASP.NET 2.0 Basics 0 February 9th, 2007 06:22 PM
FormatCurrency Function Question kwilliams VBScript 0 May 12th, 2006 09:17 AM
Problem with Exercise in Beg. asp.net for VB.net! mrfella71 BOOK: Beginning ASP.NET 1.0 1 October 23rd, 2005 12:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.