Hey guys

I'm trying to debug a program which gets values from a Sybase database and exports those data to a Excel Worksheet, all is fine but when there is a value '001' from the database the exported valued to the worksheet is a null character.
That is strange so i'm wondering if any of you's ever encountered something like that .... the closest thing I could find that would do any sort of filtering is the code below:

If rs("db_value").Value <> vbNull Then
    // Add value to worksheet
End If

Could it be that '001' is interpreted as a vbNull ?
By the way "db_value" is a varchar.

Regards
Edmond

I do not think the problem Lies with your data but the format the text is added to excell. You can either manualyy change this by right clicking on the cell, select 'Format Cell', select number, or you can do this via code as follows -

Reference MS Excell Object Library under references

Dim MyExcel As Excel.Application

On Error Resume Next

Set MyExcel = GetObject(, "Excel.Application")

MyExcel.ActiveCell.NumberFormat

Let me know if this solved your problem.

Hi AndreRet, thanks for your reply.
I found out the answer ... it seems that vbNull character is in fact "1" so when i'm comparing "001" to vbNull (1) it matches hence causing the error.

Hope this helps others !

I'm glad you could solve your problem. Happy coding....

Please mark this thread as solved when done, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.