Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Simple unusual variable problem

Reply
Thread Tools

Simple unusual variable problem

 
 
Bramo
Guest
Posts: n/a
 
      09-24-2004
Hi guru guys,

I have serious problem. At first sight it looks very simple but i dont
have any idea how to solve it.

With this statement 'If len(rs_cit) = 0 then rs_cit = 0' I cant put
into variable 'rs_cit' value '0' if it is clean. There is no value in
html displayed.

Here is code:

....
Dim rs_customer, rs_cit, rs_total, rs_manual

i = 1
Do While Not RS.Eof

rs_customer = RS("customer")
rs_account = RS("account")
rs_cit = RS("cit")
rs_total = RS("total")
rs_manual = rs_total - rs_cit

If len(rs_cit) = 0 then rs_cit = 0
'neither this does not work: If rs_cit = "" then rs_cit = 0


response.write ("<tr>")
response.write ("<td bgcolor='black' align='right'>" & i & ".</td>")
i = i + 1
response.write ("<td bgcolor='black'>" & rs_account & "</td>")
response.write ("<td bgcolor='black'>" & rs_customer & "</td>")
response.write ("<td align='center' bgcolor='#666666'>" & rs_cit &
"</td>")
response.write ("<td align='center' bgcolor='#666666'>" & rs_manual &
"</td>")
response.write ("<td align='center' bgcolor='#666666'>" & rs_total &
"</td>")
response.write ("</tr>")
RS.MoveNext
Loop
....
 
Reply With Quote
 
 
 
 
David Morgan
Guest
Posts: n/a
 
      09-24-2004
rs_cit = RS("cit") might be null. In some cases using Len can be
unreliable.

Try

If IsNull(rs_cit) Or Len(rs_cit) = 0 Then rs_cit = 0


"Bramo" <> wrote in message
news: om...
> Hi guru guys,
>
> I have serious problem. At first sight it looks very simple but i dont
> have any idea how to solve it.
>
> With this statement 'If len(rs_cit) = 0 then rs_cit = 0' I cant put
> into variable 'rs_cit' value '0' if it is clean. There is no value in
> html displayed.
>
> Here is code:
>
> ...
> Dim rs_customer, rs_cit, rs_total, rs_manual
>
> i = 1
> Do While Not RS.Eof
>
> rs_customer = RS("customer")
> rs_account = RS("account")
> rs_cit = RS("cit")
> rs_total = RS("total")
> rs_manual = rs_total - rs_cit
>
> If len(rs_cit) = 0 then rs_cit = 0
> 'neither this does not work: If rs_cit = "" then rs_cit = 0
>
>
> response.write ("<tr>")
> response.write ("<td bgcolor='black' align='right'>" & i & ".</td>")
> i = i + 1
> response.write ("<td bgcolor='black'>" & rs_account & "</td>")
> response.write ("<td bgcolor='black'>" & rs_customer & "</td>")
> response.write ("<td align='center' bgcolor='#666666'>" & rs_cit &
> "</td>")
> response.write ("<td align='center' bgcolor='#666666'>" & rs_manual &
> "</td>")
> response.write ("<td align='center' bgcolor='#666666'>" & rs_total &
> "</td>")
> response.write ("</tr>")
> RS.MoveNext
> Loop
> ...



 
Reply With Quote
 
 
 
 
Dave Anderson
Guest
Posts: n/a
 
      09-24-2004
Bramo wrote:
> With this statement 'If len(rs_cit) = 0 then rs_cit = 0' I cant put
> into variable 'rs_cit' value '0' if it is clean. There is no value in
> html displayed.
> ...
> rs_cit = RS("cit")
> ...
> If len(rs_cit) = 0 then rs_cit = 0
> 'neither this does not work: If rs_cit = "" then rs_cit = 0


For what it's worth, this is all you need to meet your needs in JScript:

rs_cit = RS.Fields("cit").Value || 0


It is sufficient because JScript coerces null and empty string values into
false boolean values when used in conditional assignment constructions.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unusual problem with Session variables in IIS6 Jacob Arthur ASP .Net 1 03-01-2006 01:47 PM
Unusual problem with smartnav Dan ASP .Net 1 01-06-2006 04:48 PM
ICS unusual problem richardewing@gmail.com Wireless Networking 2 04-14-2005 09:35 AM
Following Up: Unusual Solution To Vid Capture Problem Pete Holland Jr. Computer Support 2 12-31-2003 05:59 AM
Unusual performance problem. William A. Sempf ASP .Net 2 08-27-2003 10:59 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57