Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 17th, 2003, 03:59 PM
abc88 abc88 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: In a house
Posts: 3 abc88 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!!!!!

Reply With Quote
  #2  
Old December 17th, 2003, 06:51 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Do U have a real number in a excel,and it's truncated when write it into another excel??Plz say your problem detailed!.

Reply With Quote
  #3  
Old December 22nd, 2003, 05:14 PM
Lee Miles Lee Miles is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 7 Lee Miles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old December 22nd, 2003, 05:22 PM
Lee Miles Lee Miles is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 7 Lee Miles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old December 22nd, 2003, 06:07 PM
abc88 abc88 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: In a house
Posts: 3 abc88 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #6  
Old December 22nd, 2003, 07:15 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I am agreed with Lee Miles!This problem maybe is caused by excel number format!..U can try to change it??

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Help with Truncation?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway