473,512 Members | 14,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Validation

blyxx86
256 Contributor
Can I have someone take a look at this code and let me know if you see any problems with it... In terms of efficiency, error control, etc... :) Thank you! This is my first completely self created Function.

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     Function WebTracking(sTracking) 
  3.     Dim shipArray(2)
  4.         shipArray(0)="<a href=""http://www.fedex.com/Tracking?tracknumbers="
  5.         shipArray(1)="<a href=""http://www.calover.com/trackres.asp?tracking_number="
  6.         shipArray(2)="<a href=""http://wwwapps.ups.com/WebTracking/processInputRequest?AgreeToTermsAndConditions=yes&tracknum="
  7.  
  8.         If IsNull(sTracking) Then
  9.             LenTracking = 0
  10.         Else
  11.             LenTracking=Len(sTracking)
  12.         End If
  13.  
  14.         Select Case LenTracking
  15.             Case 12 'Fedex length
  16.                 WebTracking = shipArray(0) & sTracking & """>" & sTracking & "</a>"
  17.             Case 15 'California Overnight / FedEx Ground Length
  18.                 If UCase(Left(sTracking,1)) = "C" Then 'California Overnight
  19.                     WebTracking = shipArray(1) & sTracking & """>" & sTracking & "</a>"
  20.                 Else 'FedEx Ground
  21.                     WebTracking = shipArray(0) & sTracking & """>" & sTracking & "</a>"
  22.                 End If
  23.             Case 18 'UPS Length
  24.                 WebTracking = shipArray(2) & sTracking & """>" & sTracking & "</a>"
  25.             Case 20 'Fedex Ground
  26.                 WebTracking = shipArray(0) & sTracking & """>" & sTracking & "</a>"
  27.             Case Else
  28.                 WebTracking = sTracking
  29.         End Select
  30.     End Function 
  31. %>
  32.  
I stored the values in an array to hopefully speed up processing. I haven't seen any slowed down pages from this new script... Again, my very first Function, let me know! :) I'll be adding some comments in the code as well later on.
Dec 13 '07 #1
5 1363
Nicodemas
164 Recognized Expert New Member
Looks fine to me... you could try wrapping all concatenations with parenthesis. You might get a millisecond or two out of it :D
Dec 13 '07 #2
blyxx86
256 Contributor
What do you mean wrapping in Parenthesis? I've not heard of this before...
Expand|Select|Wrap|Line Numbers
  1. sWebTracking = (sWebTracking & "something " & sSomethingElse)
  2.  
???
Dec 13 '07 #3
Nicodemas
164 Recognized Expert New Member
Yeah, pretty much exactly what you have there.

I've heard it makes things speedier, given ASP VBScript's concatenation efficiency (of which I have no benchmarks to show you or tell you about.) It's just one of those lores you hear thrown about. But, maybe you'll be the one to debunk it :D
Dec 14 '07 #4
blyxx86
256 Contributor
I'd love to debunk it.. Perhaps you know of some code to capture information in milliseconds? I believe the "Now()" returns only seconds... Better yet, I'll just provide the code I found at: http://classicasp.aspfaq.com/general...-asp-code.html

Expand|Select|Wrap|Line Numbers
  1. <% 
  2.     ' get timer before task begins: 
  3.  
  4.     starttime = Timer() 
  5.  
  6.     ' do some task, e.g.: 
  7.  
  8.     Do While z < 350000 
  9.         z = z + 1 
  10.     Loop 
  11.  
  12.     ' get timer after task completes: 
  13.     endtime = Timer() 
  14.  
  15.     ' display results: 
  16.     Response.Write "The task completed in " & endtime-starttime & " s" 
  17.     Response.Write " (" & (endtime-starttime)*1000 & " milliseconds)." 
  18. %>
  19.  
Dec 14 '07 #5
Nicodemas
164 Recognized Expert New Member
Eh, this won't give you the exact measure of milliseconds, because all your doing is multiplying by 1000. Multiplying by 1000 only provides the exact data, but represented by a different unit of measurement.

1 second will always = 1000 milliseconds
20 seconds will always = 20,000 milliseconds.

I say this because I believe that, when a time measurement is called, VBScript supplies only the nearest whole second, i.e. you'll never get 21.2 second measurements.
Dec 14 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

21
3881
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
2
2132
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For...
4
2590
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. ...
14
6268
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
6
2400
by: Stephen | last post by:
Hi, the validation controls dont work on Netscape or Mozilla and only on Internet Explorer why? How do i correct this problem? Thanks
7
2032
by: Ryan Ternier | last post by:
We're running a site that has required field validation on the login page. It works fine on our development / test machines. However, when I upload this site to our live server i get this error. ...
5
3224
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
4
2960
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
2
4492
by: dustbort | last post by:
I recently had a problem where my required field validator stopped working. But, the page still posted back and tried to insert a record into the database without performing server-side validation....
6
3339
by: Jon Paal | last post by:
validation doesn't fire what's missing ????? /////// ---- code -----/////////////////////////// Sub btnSubmit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) 'Handles...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.