Solved

converting null to " "

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

17 Experts available now in Live!

Get 1:1 Help Now