Null Function in Visual Basic????

Posted on 2006-05-28
Last Modified: 2013-11-25

I am exporting some data from a table into a fixed width file. The problem i have is that lots of the values are Null. I was getting around this by doing the following:

If IsNull(objGRNList("UNIT_QTY")) = True Then
    strGRNListQty = ""
    strGRNListQty = objGRNList("UNIT_QTY")
End If

This works, but the problem is that i've got over 20 fields to do this for. I started looking at writing a function, but VB won't let me pass a null value to a function, so i'm struggling

Any ideas please?

Question by:seancurt
    1 Comment
    LVL 10

    Accepted Solution


    Try tagging an 'empty string onto the front on your variables, ie.

    strGRNListQty="" & objGRNList("UNIT_QTY")


    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

    Introduction While answering a recent question ( 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…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    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…
    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…

    732 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

    20 Experts available now in Live!

    Get 1:1 Help Now