
June 25th, 2001, 05:26 PM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 23
|
|
|
<i><b>Originally posted by : Jerry Scannell (JScannell1@home.com)</b></i><br /><br /><br /><br />------------<br />Mal at 5/3/2001 10:48:40 AM<br /><br /><% for i = 0 to howmanyfields<br /> ThisRecord = MyRs(I)<br /> If IsNull(ThisRecord) Then<br /> ThisRecord = " "<br />end if %><br /><br />Can anyone see whats wrong with above code ?? If the field is empty a space is supposed to be inserted....but it isn't working.<br /><br />Cheers<br /><br />Basically, if ThisRecord doesn't end up as a single space, then ThisRecord wasn't determined to be null by the IsNull() function. <br /><br />There is a quirk that I have been struggling with as far as ASP is concerned with the basic question: "What is a Null, anyway?" <br /><br />Since VB Scripts really don't know what data types are (you have to call IsNull(), or IsNumber(), or IsDate() to find out) I think it has a problem answering the IsNull() question when it doesn't think the data is a String! If you think about it. if VB Scripts assumed something was a number and it came up empty, it wouldn't answer IsNull() = True. I'm convinced that we are all left out there hanging on this.<br /><br />I had to design a workaround that works every time so far.<br /><br />here is a function that works:<br />Function IsBlank ( string )<br /> Dim Local_String<br /> Local_String = Trim ( string )<br /> if len ( Local_String ) = 0 then<br /> IsBlank = True<br /> else<br /> IsBlank = False<br /> end if<br />end Function<br /><br />To use it:<br /><br />if IsBlank ( string ) then<br /> Local_String = " "<br />else<br /> Local_String = Cstr( string )<br />end if<br /><br /><br />Setting it equal to " " makes the variable a string, and Cstr() forces the issue on a previously unknown data type. <br />
|