View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Excel VBA vs Time fields

Hi CDate function converts recognizable date strings to dates that can be
used in the maths.

Dim strdate As String
Dim dateValue As Date

Examples:-
strdate = "2 March 2008" 'Can be this format in string
strdate = "March 2 2008" 'or this format in string

'If using following date format in string then must be as per date format
'used by uour computer for your region
strdate = "2/3/08"

dateValue = CDate(strdate) 'Converts to a date that can be used with maths

--
Regards,

OssieMac


"Cavalierfool" wrote:

Hey all, sort of teaching myself excel and vba to simplify some work, done a
lot of reading but I'm not getting the hang of one aspect.

I need to have two time fields in my form, in which the user will enter a
value of minutes and seconds, in the format of mm:ss, have it stored in a
cell pointed to by other factors (arbitrarily use A1 and B1 for example
purposes) with the ability to be mathematically manipulated by fields filled
with integer values (A2, B2, C1) with results stored in field (D1 such that

D1 = ((A1 * A2) + (B1 * B2))/C1

I think the core problem I'm having is getting the Data entered into the
TextBox to translate as not a string, and am a little lost, I believe the
math will work fine whats it's actually a time in excel's view, so it's
really the VBA code side of things I need.

Thanks for any advice.