Array Values

netpicker9

Member
Joined
Dec 8, 2004
Messages
17
Programming Experience
1-3
Hi,

I am getting a Array of Values from vb.net dll. The Array containes all types of values..
I am displaying data on aspx page from that array. Problem is,
Arr(0,5) is returning 0.0 {Double}

Arr(1,5) is returning "" {String}

While displaying data in aspx page.. I wrote.

Dim totAll as Double
totAll = String.Format("{0:c}", Arr(i,5))

I am getting Error at this line as Conversion from string to type 'Double' is not valid. only for Arr(1,5). Arr(0,5) is fine

How to avoid this error?

Other options I tried
totAll = String.Format("{0:c}", Convert.ToDouble(Arr(i,5))) --> Error --> Input string was not in a correct format. Because Arr(1,5) is giving "".

I am using VB.net with Visual Studio 2005. I prefer VB.net code.

Thanks
 
If you are getting an array of strings you can't format those values as if they were doubles. Your conversion ToDouble (or CDbl function) is fine if all values are expected to be doubles returned as strings. For the missing items "" you set them to "0" before converting. If you wrote the dll perhaps is was better if you returned correct type of data (ie doubles instead of strings) in the first place?
 
Back
Top