Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




113 posts

Master Geek


# 19730 28-Feb-2008 12:09
Send private message

Sounds easy enough, but cause its for a webpage and not a windows form I cant run any process to validate text as its being typed.

My order entry screen takes a whole lot of measurements that are in the form 1.23.  I'd like my users to only need to enter 123 and have the formatting all taken care of for them, but have it update the textbox as they go.  I've had an extensive search on google and cant seem to find what I'm after. 

Everything has been developed in visual studio 2008 in vb.net.  First person to give me an answer that works can have $10 transfered into their bank account by leaving their bank acconut number.  Boy I hope this thread doesnt get shut down for this.

View this topic in a long page with up to 500 replies per page Create new topic
 1 | 2
I iz your trusted friend
5833 posts

Uber Geek
+1 received by user: 147

Mod Emeritus
Trusted
Lifetime subscriber

  # 113514 28-Feb-2008 12:24
Send private message

VBScript: output=round(input/100,2)

To use it on textbox on HTML (pseudo-AJAX). Employ the technique of using "onchange" to call a javascript to make the rounding.

Alternatively, the user fill it in in cents (123 cents = $1.23) then submit away and on the server end, it gets calculated and processed.




Internet is my backyard...

 

«Geekzone blog: Tech 'n Chips Takeaway» «Personal blog: And then...»

 

Please read the Geekzone's FUG

 




113 posts

Master Geek


  # 113515 28-Feb-2008 12:27
Send private message

but how do I get that to do as I require? realtime formatting etc.

 
 
 
 


I iz your trusted friend
5833 posts

Uber Geek
+1 received by user: 147

Mod Emeritus
Trusted
Lifetime subscriber

  # 113516 28-Feb-2008 12:32
Send private message

you must decide where does this take place, and when entered/processed, does the server validate the calculation before it gets put into DB or wherever?

Also, another thing I learn with the appropriate accounting calculation is, hundred-fy the value, calculate it, then divide it by 100 again to get a more accurate rounding.

for example:

if to calculate the addition of 123.45 and 456.23. You first hundred-fy both of the values. 12345+45623=57968, then divide by 100, so it became 579.68. This may seem unncessary but when you have a lot of decimal places, the every little decimals count towards accounting accuracy.




Internet is my backyard...

 

«Geekzone blog: Tech 'n Chips Takeaway» «Personal blog: And then...»

 

Please read the Geekzone's FUG

 




113 posts

Master Geek


  # 113518 28-Feb-2008 12:35
Send private message

takes place on the server, and when entered.  Dont want the users to have to push a button to recalc numbers or anything like that.

Phil Gale
1108 posts

Uber Geek
+1 received by user: 45

Trusted
Red Jungle
Subscriber

  # 113519 28-Feb-2008 12:35
Send private message

If you want it done in realtime you'll need to use javascript to validate and reformat the input using the onKeyPress event of the textbox.

It's not terribly hard to do, you've probably just been googling for the wrong things.




Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype

Phil Gale
1108 posts

Uber Geek
+1 received by user: 45

Trusted
Red Jungle
Subscriber

  # 113520 28-Feb-2008 12:38
Send private message

In fact, two seconds of googling lead me to this forum post where someone is wanting to do pretty much exactly the same thing:

http://forums.asp.net/p/1223093/2193368.aspx

More info here:
http://www.codeproject.com/KB/scripting/Form_field_input_mask.aspx




Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype

I iz your trusted friend
5833 posts

Uber Geek
+1 received by user: 147

Mod Emeritus
Trusted
Lifetime subscriber

  # 113521 28-Feb-2008 12:42
Send private message

I agreed. It isn't a hard bit of coding... Javascript for HTML realtime formatting.

When submitted to server, your best bet will be looking for accuracy and not calculation/formatting (right?)




Internet is my backyard...

 

«Geekzone blog: Tech 'n Chips Takeaway» «Personal blog: And then...»

 

Please read the Geekzone's FUG

 


 
 
 
 




113 posts

Master Geek


  # 113522 28-Feb-2008 12:42
Send private message

I'd rather not use Java, want to keep it to VB.  if thats the only way to get it to go then I might just flag it.

Phil Gale
1108 posts

Uber Geek
+1 received by user: 45

Trusted
Red Jungle
Subscriber

  # 113525 28-Feb-2008 12:49
Send private message

Note this is javascript and not Java (you might be just shorthanding, but just in case - the two are different languages). I'm not sure why you're not keen on javascript - it's the correct (read standard) solution for this problem, but thats up to you. It is possible to use VBScript to handle the onKeyPress event as well - however VBScript is only supported by IE so you'll lose cross browser compatibility.

If you're just not confident with writing javascript then consider using the asp.net ajax extensions along with the masked edit extender from the ajax control tool kit (which will produce javascript for you without you needing to deal with client side script).




Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype

95 posts

Master Geek


  # 113561 28-Feb-2008 15:07
Send private message


As above, if you want code to execute at the client end Javascript is the correct thing to use.  The main processing still takes place in VB code at the server end but the Javascript is used to validate and format stuff at the client end BEFORE it gets posted back to ASP.NET / server.

http://msdn2.microsoft.com/en-us/library/3hc29e2a.aspx

http://msdn2.microsoft.com/en-us/library/ms178207.aspx

DS



113 posts

Master Geek


  # 113562 28-Feb-2008 15:09
Send private message

thanks but I dont want to use any javascripts.

95 posts

Master Geek


  # 113563 28-Feb-2008 15:12
Send private message


The point is that you MUST use client-side Javascript if you want stuff to happen AS THE USER TYPES.  VB.NET inside ASP pages only runs at the server so therefore the user needs to hit SUBMIT to send it to the server before your VB code sees it (and can act on it). 

The only code that can take action as the client types is stuff running inside the browser - Javascript, VBscript or a java applet. 

Javascript is the right choice here and not complex.


DS

I iz your trusted friend
5833 posts

Uber Geek
+1 received by user: 147

Mod Emeritus
Trusted
Lifetime subscriber

# 113566 28-Feb-2008 15:19
Send private message

you can't help those who are not willing to be helped.




Internet is my backyard...

 

«Geekzone blog: Tech 'n Chips Takeaway» «Personal blog: And then...»

 

Please read the Geekzone's FUG

 




113 posts

Master Geek


  # 113570 28-Feb-2008 15:29
Send private message

Im thinking red jungle's and signz's suggestions of using a vbscript sounds good, keep it all the same flavour.  None of our target audience will be using firefox or opera or anything other than IE. 

Phil Gale
1108 posts

Uber Geek
+1 received by user: 45

Trusted
Red Jungle
Subscriber

  # 113572 28-Feb-2008 15:35
Send private message

You'll find the code and syntax that you'll be using to implement this in VBScript is very similar to the Javascript needed (plus is pretty much provided for you in those links I posted).

It's the last time I'll try to convince you, but I urge you to look into using javascript instead - these days it's actually quite an elegant  and robust language thats worth knowing if you're going to be developing web sites or web applications.




Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype

 1 | 2
View this topic in a long page with up to 500 replies per page Create new topic



Twitter and LinkedIn »



Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

Xero announces new smarter tools, push into the North American market
Posted 19-Jun-2019 17:20


New report by Unisys shows New Zealanders want action by social platform companies and police to monitor social media sites
Posted 19-Jun-2019 17:09


ASB adds Google Pay option to contactless payments
Posted 19-Jun-2019 17:05


New Zealand PC Market declines on the back of high channel inventory, IDC reports
Posted 18-Jun-2019 17:35


Air New Zealand uses drones to inspect aircraft
Posted 17-Jun-2019 15:39


TCL Electronics launches its first-ever 8K TV
Posted 17-Jun-2019 15:18


E-scooter share scheme launches in Wellington
Posted 17-Jun-2019 12:34


Anyone can broadcast with Kordia Pop Up TV
Posted 13-Jun-2019 10:51


Volvo and Uber present production vehicle ready for self-driving
Posted 13-Jun-2019 10:47


100,000 customers connected to fibre broadband network through Enable
Posted 13-Jun-2019 10:35


5G uptake even faster than expected
Posted 12-Jun-2019 10:01


Xbox showcases 60 anticipated games
Posted 10-Jun-2019 20:24


Trend Micro Turns Public Hotspots into Secure Networks with WiFi Protection for Mobile Devices
Posted 5-Jun-2019 13:24


Bold UK spinoff for beauty software company Flossie
Posted 2-Jun-2019 14:10


Amazon Introduces Echo Show 5
Posted 1-Jun-2019 15:32



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.