Numeric column in Excel

K

KK

Hi,

Please check the code snippet below. I want the 4th column be numeric.
But, in the result it is always showing as text.

Any suggestions to show this column as numeric?

Thanks.




XLSConn = New ADODB.Connection
XLSConn.Open("Provider=Microso­ft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDestination & _
";Extended Properties=""Excel 8.0;HDR=NO;""")


Dim source As String
Dim arrData
Dim Counter As Integer
source = "Select * from [A6:G6" & "$" & strRecRange &
"]"
XLSrs.Open(source, XLSConn, 1, 3)
arrData = Split(strRec, Chr(9))

For Counter = LBound(arrData) To UBound(arrData) - 1
If Counter = 4 Then 'this column must be integer
XLSrs.Fields(Counter).Value =
Integer.Parse(arrData(Counter))
Else
XLSrs.Fields(Counter).Value = Left(arrData(Counter),
255)
End If
Next


XLSrs.Update()
XLSrs.Close()
 
G

Guest

i am not sure, but are arrays in Excel zero based? If so then the first
column is array index(0), and the fourth column is array index(3), not
array(4).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top