Data Type conversion problems

Results 1 to 5 of 5

Thread: Data Type conversion problems

  1. #1
    Ed B Guest

    Default Data Type conversion problems

    Hi, <BR>I originally posted this query yesterday - I have supplied my code below this time. Any hints as to why I can&#039t do maths on a numerical value returned from a Request.Form() on one page when the code works on another?<BR><BR>Code follows...NB "oSis" refers to a GIS mapping component which appears as an IMAGE type of FORM &#060;INPUT&#062; element.<BR><BR>&#039=== Troublesome code - "Type mismatch" when dividing by w<BR>&#039=== I have already tried CDbl etc<BR>&#039=== plus used a function to convert from string to numbers<BR><BR>w = Request.Form("width")<BR>h = Request.Form("height")<BR><BR><BR>&#039=== Scale bar width calculation<BR><BR>&#039 get width & height in x & y<BR> oSis.SplitExtent x1,y1,z1,x2,y2,z2,oSis.GetViewExtent<BR><BR> bar_width = 1000<BR> pix_width = (x2 - x1) / w<BR><BR> scale_factor = bar_width / pix_width<BR><BR> While scale_factor &#062; 250<BR> bar_width = (bar_width / 2)<BR> scale_factor = bar_width / pix_width<BR> Wend<BR><BR> While scale_factor &#060; 100<BR> bar_width = (bar_width * 2)<BR> scale_factor = bar_width / pix_width<BR> Wend

  2. #2
    Panos Barbalias Guest

    Default RE: Data Type conversion problems

    Hello.First of all, change this:<BR>w = Request.Form("width") to"<BR>intW = Int(Request.Form("width"))<BR>add the Int thing where you are requesting variables..<BR>I thing you are getting numbers as a string..<BR><BR>A good way to see it is to make a simple math and Response.write it...<BR>ie:<BR>total = w + h<BR>Response.Write "What I get is:" & total<BR><BR>so you can see if the math calculation has been executed.

  3. #3
    Ed B Guest

    Default RE: Data Type conversion problems

    Thank you Panos, I will try this and let you know what happens.

  4. #4
    Ed B Guest

    Default RE: Data Type conversion problems

    The results I got have shown that something odd is happening - the value of intW and intH is two comma separated values - I must be doing something odd elsewhere in the page (at 600 - odd lines it&#039s a bit too big to post, unfortunately!)<BR><BR>Here&#039s the results of Response.Write(total) where total = intW + intH, plus the error message:<BR><BR>450, 200255, 255 &#039=== intW = 450, 200, intH = 255, 255<BR><BR>&#039=== the latter value in each pair is a default value if <BR>&#039=== Request.Form("width") = ""<BR>&#039=== The first value in each pair is returned from the <BR>&#039=== SELECT form element.<BR>&#039=== Error message follows - self explanatory really.<BR><BR>Microsoft VBScript runtime error &#039 800a000d&#039 <BR><BR>Type mismatch: &#039[string: "450, 200"]&#039 <BR><BR>/thames/gis/thames/demo07.asp, line 90 <BR><BR>I shall go back to the drawing board. Thanks for your help!<BR>

  5. #5
    Ed B Guest

    Default I can't believe how stupid I am!

    There&#039s a lesson here for all numbskulls like me - if it doesn&#039t work, CHECK YOUR CODE!<BR><BR>I had TWO form elements with the same name, hence lots of bizarre results. It all works again now.<BR><BR>Many thanks to all those that helped me.<BR><BR>Mr Sheepish

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts