Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot recognize variable as blank

Status
Not open for further replies.

spacehawk

Programmer
May 17, 2000
30
US
I have a table from which I select all records and place the fields into an array using a do while loop.<br><br>To process them I need to know whether List(h,2) is blank.<br><br>I put the following code in:<br><br>If List(h,2)&lt;&gt;&quot;&quot; Then<br> Response.Write(List(h,0) & List(h,1) & List(h,2) & List(h,3) & List(h,4) & &quot;&lt;br&gt;&quot;)<br>Else<br> Response.Write(&quot;It is blank.&quot; & MateList(h,2) & &quot;*&lt;br&gt;&quot;)<br>End If<br><br>It always returns the else choice for every record.&nbsp;&nbsp;So I changed the &lt;&gt; in the first line to =.&nbsp;&nbsp;It still returned the else choice every time.<br><br>Every time I run this program, whether I put equal or not equal to blank, it prints &quot;It is blank.&quot; on the screen.&nbsp;&nbsp;How can this be?<br><br>My first thought was that maybe I didn't save when I made the change, so I went back and checked, saved, and reloaded the page several times.&nbsp;&nbsp;It still returns the else choice whether I have equal or not equal in the If Then statement.<br>
 
Thanks guestg,<br><br>I tried your suggestion.&nbsp;&nbsp;It stil returned the else choice, so I added:<br><br>Response.Write(Len(list(h,2)) & &quot;&lt;br&gt;&quot;)<br><br>It returned a blank.&nbsp;&nbsp;I'm not sure what that means.
 
spacehawk:<br><br>It field is having data &quot;&quot; or null. <br>if it is null the change your if else for null or &quot;&quot; checking.<br><br>Try it.<br><br>Anand
 
you could also use the IsEmpty() boolean function, to check to see if it's empty, not sure if it'll apply the same here. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
May be it's a stupid question to ask, but have you tried to check what's there in your array?
 
spacehawk, try this one too. Sometimes, you just don't know<br>what is really returned(null,space,empty)<br>If isempty(List(h,2)) or len(List(h,2))&lt; 1 Then<br>Response.Write(&quot;It is blank.&quot; & MateList(h,2) & &quot;*&lt;br&gt;&quot;)<br>Else<br>Response.Write(List(h,0) & List(h,1) & List(h,2) & List(h,3) & List(h,4) & &quot;&lt;br&gt;&quot;)<br>End If<br><br>And definitely check if you do have something in your array<br>
 
Thanks everyone for all the quick responses.&nbsp;&nbsp;It finally responded to the Not IsEmpty call.&nbsp;&nbsp;It selected the &quot;then&quot; choice for If Not IsEmpty(List(h,2)) Then.&nbsp;&nbsp;However, there is nothing in the record in the table.&nbsp;&nbsp;When I do a response.Write(List(h,2)), it returns nothing.&nbsp;&nbsp;<br><br>Therefore, I don't see how I can distinguish it from records that have data in the field.&nbsp;&nbsp;They will also be not IsEmpty.<br><br>I really appreciate the tips.&nbsp;&nbsp;Can anyone tell me what is happening here?&nbsp;&nbsp;Is there an &quot;IsNull&quot; expression of some kind?
 
Could you tell why you use a 2-dimensional array?<br>And secondly, you might want to process nulls before you add an item into the array<br>Something like that:<br>redim arr(0)<br>count = 0<br>while not rs.eof<br>if not isnull(arr(count))then<br>arr(count)= rs(&quot;somefield&quot;)<br>else<br>arr(count)= &quot;*&quot;<br>end if<br>redim preserve arr(count + 1)<br>count = count + 1<br>rs.movenext<br>Wend<br><br><br>
 
Thanks.&nbsp;&nbsp;The IsNull and not IsNull worked.&nbsp;&nbsp;I have it going like I want now. <br><br>I am using the 2D array to get the fields from the first record as List(0,0), List(0,1), List(0,2), List(0,3), etc.<br><br>I like the idea of the if then with the IsNull choice.&nbsp;&nbsp;I will use that.
 
I'm sorry, there is a mistake in a code:<br>it should read<br><i>if not isnull(rs(&quot;somefield&quot;))or len(rs(&quot;somefield&quot;))&lt; 1 then...</i><br><br>
 
Sorry, again.I made a mistake again<br>May be I'm just tired. Here's the last attempt to correct it:<br><b>if not isnull(rs(&quot;somefield&quot;))then...</b><br><br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top