Solved

converting null to " "

Posted on 1998-10-23
5
151 Views
Last Modified: 2010-04-30
I have a user defined type with fixed length strings.  When I print out to a file, if the string is empty, it is putting null characters in the file.  I need it to just have empty spaces.  I have tried reading each character using IsNull and check and replacing with " ", but it didn't work.  How do I get it to print out the file with empty spaces and not nulls?
0
Comment
Question by:LJ083198
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
mark2150 earned 30 total points
ID: 1441316
You shouldn't be getting "null" characters You should be getting *no* characters.

Try:

IF LEN( MyString ) < 1 THEN MyString = Space$( n )

where N is number of bytes to fill
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1441317
Can you show your code? How are you writing it out to the file currently?
0
 

Author Comment

by:LJ083198
ID: 1441318
Mark2150's solution would certainly work, but I have over 80 fields in each record of which half might be empty.  I was looking for a way to  check the whole thing for null and replace with a space, without doing each field individually.  
In response to BergJC I aam using a print# command.  When the file is opened it looks fine, and it has all it's spaces.  The problem comes when the file is used in the next application, the null are picked up as spaces.  They are essentially eliminated from the file.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1441319
Do you have control over the next application? This might be something that could be solved in the receiving application. Assuming, of course, that you do have control over the receiving app, which may not be the case.
0
 

Author Comment

by:LJ083198
ID: 1441320
unfortuantely no, I don't have control over the next application.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question