Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB Excel Object

Posted on 2002-05-29
3
Medium Priority
?
147 Views
Last Modified: 2010-05-02
Hello,

I am writing an import routine to import data from an Excel spreadsheet into a SQL Server database.  The problem I am having is that one of the columns has a formatting on it and I can't retrieve the data as it appears.  Here is the info about this column:

Column name:         AS4TIME
Visual Appearance:   12:42:49
Fx (formula bar):    12:42:49 PM
Formatted as text:   0.529733796

My code is as follows:

pxlSheet.Cells(lngCurrentRecord, TIME_COL).Value
This returns:  0.529733796, which is unacceptable

so I tried:
pxlSheet.Cells(lngCurrentRecord, TIME_COL).Text
This returns: 12:42:49, which is what you see when you view the spreadsheet, but I need that 'PM' that appears in the formula bar.

I don't want to modify the sheet in any way.  Any help in retrieving 12:42:49 PM from this cell would be greatly appreciated
0
Comment
Question by:dentyne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Expert Comment

by:Crin
ID: 7042788
Hi,

use CDate(pxlSheet.Cells(lngCurrentRecord, TIME_COL).Value)

Sincerely,
Crin
0
 
LVL 2

Accepted Solution

by:
Crin earned 400 total points
ID: 7042794
Sorry, forgot AM-PM issue:

Format(CDate(pxlSheet.Cells(lngCurrentRecord, TIME_COL).Value), "hh:mm:ss AMPM")

SIncerely,
Crin
0
 
LVL 1

Author Comment

by:dentyne
ID: 7042826
Hey that's great; thanks for the help!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question