Spellnumber in InfoPath - InfoPath Dev
in

InfoPath Dev

Spellnumber in InfoPath

Last post 09-14-2015 07:20 AM by Hilary Stoupa. 44 replies.
Page 3 of 3 (45 items) < Previous 1 2 3
Sort Posts: Previous Next
  • 06-16-2009 01:37 AM In reply to

    Re: Spellnumber in InfoPath

    Thanks Jimmy, that worked like a charm!  I'd never have figured out that out but so I know for the future, am I right in thinking you determined the correct namespace by saving as source files and then opening the .xsd file in notepad?  It's a great piece of code so it's really helpful to understand how to move it into other forms.

    I was also wondering, with you and Hilary being the InfoPath geniuses you are, if you'd mind looking at another issue I've posted on here that has me stumped (it's always the things that seem like they should be so simple that cause the most hassle in InfoPath!)?

    http://www.infopathdev.com/forums/p/12086/42365.aspx#42365

    Thanks again!

  • 06-16-2009 03:57 AM In reply to

    Re: Spellnumber in InfoPath

     Hey Ben,

     Glad it worked out.  You can actually find out the namespace URN of any node (typically all the nodes in your main data source will have the same namespace), by opening the node's properties in the Data Source taskpane, and looking at the Details tab.

     I couldn't come up with a great response to your other inquiry, but I did come up with a solution of sorts.  Please go have a look when you get the chance.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-09-2009 02:46 AM In reply to

    HI all, I've just encountered a small bug that's occurring with this code.  When a user enters in a value for my:ChequeAmount, the text generated in the my:AmountWords field is sometimes off by a penny.  I've gone through and tested all denominations and it appears that the pence (cents) are falling short on occurrences of .14, .17, .20, .23, .39, .42, .45, .48, .64, .67, .70, .73, .89, .92, .95 and .98. 

    So basically if a user inputs £150.98 into the my:ChequeAmount field, my:AmountWords is spelling out One Hundred Fifty Pounds and Ninety-Seven Pence.  The really strange thing is that this doesn't happen every single time but is always happening with my:ChequeAmount has a pence value equal to one of the above.

    I've attached the code I'm using so if anyone has any thoughts on what could be causing this I'd be greatful for your input!

  • 11-09-2009 07:37 AM In reply to

    Re: Spellnumber in InfoPath

    You're certainly right.  This is due to small roundoff errors in floating point arithmetic causing 150.98 * 100 to produce 15097.9999999998 instead of 15098.  This should solve the problem:

     Change

    var hundredths = parseInt((num * 100 - parseInt(num) * 100));

    to

    var hundredths = Math.floor(num * 100 + 0.1) - Math.floor(num) * 100;

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-09-2009 07:52 AM In reply to

    Re: Spellnumber in InfoPath

    Thanks Jimmy, I figured it was due to some sort of rounding issue but just don't know enough about code to be able to sort it out.  This seems to have fixed the problem.

  • 12-14-2010 10:21 AM In reply to

    Re: Spellnumber in InfoPath

    Hello Hilary.  Do you still have the 2003 example in your final post? There is a problem when I click the link.  Thanks, Simon

  • 12-14-2010 10:27 AM In reply to

    Re: Spellnumber in InfoPath

    Yup, looks like the previous link fell victim to some tidying. I'll update the original post, and here's the new link.

    Hilary Stoupa

  • 01-05-2012 01:43 PM In reply to

    • Jorge
    • Not Ranked
    • Joined on 01-05-2012
    • Posts 2

    Re: Spellnumber in InfoPath

    Hello I Just did you steps but I have an Error Could be i am using Infopath 2010 I dont know i am new in this.

    This is the error

    InvalidOperationException

  • 01-05-2012 11:58 PM In reply to

    Re: Spellnumber in InfoPath

    Hello Jorge,

     That's not much information to go on.  Could you try walking the code in the debugger to find at least which is the line where the error is occurring?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-13-2012 11:12 AM In reply to

    Re: Spellnumber in InfoPath

    Jimmy, I would like to use your C# code in my InfoPath 2010 form but I need help adding code to handle decimals.  I am building a form that our accounting department will need to print checks from and need to incorporate the cents, preferably in a XX/100 format.  The provided code doesn't handle decimals at all.  Your help is much appreciated. 

    Julie

  • 07-16-2012 12:53 PM In reply to

    Re: Spellnumber in InfoPath

    I found some code that I was able to make work.  Let me know if anyone would like me to post.

    Julie :)

  • 07-27-2012 12:54 AM In reply to

    Re: Spellnumber in InfoPath

    Hi, all.

    May I ask some question about InfoPath 2010 with code-behind?

    I have develop InfoPath form using InfoPath 2010 with SharePoint 2010.

    I publish this form as Document Information Panel (DIP) content type on SharePoint and attached this SpellNum.cs to form's code-behind.

    Everything go fine when I preview this form within InfoPath on local. But when I publish this form to SharePoint with Full Trust/Create certificate, there is no luck.

    After Microsoft word has launched, it's seem code-behind does not fired to onchanged event when input number to number field in Document Property pane.

    My question is:

    1. Is this InfoPath form has deployed as sandboxed-solution?
    2. Custom code-behind worked on form service, can it worked on DIP too?

    Anyway, form formula has work perfectly but not code-behind.

    Thank you very much.

  • 09-19-2012 05:38 AM In reply to

    Re: Spellnumber in InfoPath

    chajang:
    May I ask some question about InfoPath 2010 with code-behind?

    I have develop InfoPath form using InfoPath 2010 with SharePoint 2010

     

    I have run successfully this code from Sharepoint Onine (Office 365) site both in browser and filler (Sharepoint Server 2010 + Infopath 2010)
    In order to run in browser, it is necessary to comment a line of code with MessageBox, since MessageBox is not supported in browser forms.
    I did not read all thread but while Jimmy wrote to use Expression Box for spelledNumber, I've used a text box instead.

     There is no need to attribute Full Trust and digitally sign this code (and hence administrator approval) for running published Web Browser Form template.
    It is necessary only for being able to run in preview (this Microsoft Infopath quirk which I do not completely understand).

    chajang:
    I publish this form as Document Information Panel (DIP) content type on SharePoint

    Make sure that  content type is not set as read-only upon publishing.

     

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 09-14-2015 12:45 AM In reply to

    Re: Spellnumber in InfoPath

    Hi miss Hilary, Do still have the 2010 code? Have a nice day! :) Thanks and kind regards, ~Bern
  • 09-14-2015 07:20 AM In reply to

    Re: Spellnumber in InfoPath

    Here's a link to Jimmy's initial C# code from the beginning of the thread - hope this helps: http://www.infopathdev.com/blogs/jimmy/misc/SpellNum.txt
    Hilary Stoupa

Page 3 of 3 (45 items) < Previous 1 2 3
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.