Solved

converting null to " "

Posted on 1998-10-23
5
148 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now