|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with Truncation?
Hello,
I have a vb6 program that imports some data from an excel spreadsheet and then manipulates that data and then writes the new data to a new excel spreadsheet. The problem that i am having is that the data that is written to one of the cells is of a really long number(about 65 characters in length), and when I open up the new excel spreadsheet the number has been truncated.(eg 1.32021E+66), Also the variable number that is being written back is from a list box eg: number = listBox.List(count) objExcel.application.Cells(1, 1).Value = number so does anyone know how I can get the value of "number" to write back to an excel cell without truncation? This is the last part of my program and is driving me crazy!!!!! |
|
#2
|
|||
|
|||
|
Do U have a real number in a excel,and it's truncated when write it into another excel??Plz say your problem detailed!.
|
|
#3
|
|||
|
|||
|
excel cell format
I've never programmed a VB6 - Excel app, but I'ce worked extensively in excel and the bacsic macro laguage behinf excel. it sounds like the problem may be in excel itself, I suspect your number is not actually being "truncated" excel is receiving the correct number but is displaying it in scientific format ie. 1,000,000 would be displayed as 1 X 10 to the power of 6. You can check this by running your program & going into excell and manually changing the cell format by highlighting the cell, then press "format", "cells" and selecting say "number" and the number of decimal places you want.
Maybe you should try to format the excel cell from VB BEFORE you send the number to the cell. I'm not sure of the correct syntax of function but it must be there somewhere! Alternatively, you may be able to incorporate the cell format. the Vb code might look something like .... excelcellvalue = format(number,"#0.00") Regards Lee |
|
#4
|
|||
|
|||
|
VB code (maybe?)
Just read you post again, here's posible syntax for formatting excel cell. Hope it works ...
number = listBox.List(count) objExcel.application.cell(1,1,).format = "#0.00" objExcel.application.Cells(1, 1).Value = number or maybe number = listBox.List(count) objExcel.application.cell(1,1,).format = vbNumber objExcel.application.Cells(1, 1).Value = number or maybe number = listBox.List(count) objExcel.application.Cells(1, 1).Value = format(number,"#0.00") Regards Lee |
|
#5
|
|||
|
|||
|
Re: Truncation
Thanks Lee for your tip, but alas
still not working, it is a crappy micros**t thing I think. There has to be a way around it? Any other suggestions? |
|
#6
|
|||
|
|||
|
I am agreed with Lee Miles!This problem maybe is caused by excel number format!..U can try to change it??
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Help with Truncation? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|