0

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

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by AndreRet
0

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.

0

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 !

0

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

Please mark this thread as solved when done, thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.