Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default MsgBox date & time

am learning VB / Macros ... need a MsgBox which contains both the current
date and time ... I am able to do one or the other, but not both ... what is
the syntax?

e.g. I was able to figure out MsgBox (Time) and MsgBox (Date)
but can not figure out how to get BOTH in the MsgBox
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default MsgBox date & time

Hi Skippy

use the NOW function

e.g.

MsgBox(Now)

or

Msgbox(Date & " " & Time)


--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"skippy" wrote in message
...
am learning VB / Macros ... need a MsgBox which contains both the current
date and time ... I am able to do one or the other, but not both ... what
is
the syntax?

e.g. I was able to figure out MsgBox (Time) and MsgBox (Date)
but can not figure out how to get BOTH in the MsgBox



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default MsgBox date & time

Use the Ampersand (&) to connect values. Ignore old example code online or
from old books using the + to connect values.

i.e. Msgbox(Time & " " & Date)


"skippy" wrote in message
...
am learning VB / Macros ... need a MsgBox which contains both the current
date and time ... I am able to do one or the other, but not both ... what

is
the syntax?

e.g. I was able to figure out MsgBox (Time) and MsgBox (Date)
but can not figure out how to get BOTH in the MsgBox



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default MsgBox date & time

Skippy,

The following bit of code should do what you want, if you don't want it on
two lines, just remove the CHR(13) part from the formula.

Boxdate = Date
Boxtime = Time()
boxtext = Boxdate & Chr(13) & Boxtime
MsgBox (boxtext)

HTH

Neil
www.nwarwick.co.uk

"skippy" wrote:

am learning VB / Macros ... need a MsgBox which contains both the current
date and time ... I am able to do one or the other, but not both ... what is
the syntax?

e.g. I was able to figure out MsgBox (Time) and MsgBox (Date)
but can not figure out how to get BOTH in the MsgBox

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default MsgBox date & time

May I interject?

This example, with all apologies is bad form.

The 'corrected' version of this would be:

Sub MsgDateDate()
Dim BoxDate As String
Dim BoxTime As String
Dim BoxText As String

BoxDate = Date
BoxTime = Time
BoxText = BoxDate & vbCrLf & BoxTime

MsgBox BoxText

End Sub

Or just very simply:

MsgBox(Date & vbCRLF & Time)

No need to get overly complicated.


"Neil" wrote in message
...
Skippy,

The following bit of code should do what you want, if you don't want it on
two lines, just remove the CHR(13) part from the formula.

Boxdate = Date
Boxtime = Time()
boxtext = Boxdate & Chr(13) & Boxtime
MsgBox (boxtext)

HTH

Neil
www.nwarwick.co.uk

"skippy" wrote:

am learning VB / Macros ... need a MsgBox which contains both the

current
date and time ... I am able to do one or the other, but not both ...

what is
the syntax?

e.g. I was able to figure out MsgBox (Time) and MsgBox

(Date)
but can not figure out how to get BOTH in the MsgBox





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default MsgBox date & time

Well, if you want to discuss not getting overly complicated why not just

MsgBox Now

Or

MsgBox Date & " " & Time

(and the parentheses are not required either)


"Steve Schroeder" wrote:

May I interject?

This example, with all apologies is bad form.

The 'corrected' version of this would be:

Sub MsgDateDate()
Dim BoxDate As String
Dim BoxTime As String
Dim BoxText As String

BoxDate = Date
BoxTime = Time
BoxText = BoxDate & vbCrLf & BoxTime

MsgBox BoxText

End Sub

Or just very simply:

MsgBox(Date & vbCRLF & Time)

No need to get overly complicated.


"Neil" wrote in message
...
Skippy,

The following bit of code should do what you want, if you don't want it on
two lines, just remove the CHR(13) part from the formula.

Boxdate = Date
Boxtime = Time()
boxtext = Boxdate & Chr(13) & Boxtime
MsgBox (boxtext)

HTH

Neil
www.nwarwick.co.uk

"skippy" wrote:

am learning VB / Macros ... need a MsgBox which contains both the

current
date and time ... I am able to do one or the other, but not both ...

what is
the syntax?

e.g. I was able to figure out MsgBox (Time) and MsgBox

(Date)
but can not figure out how to get BOTH in the MsgBox




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default MsgBox date & time

The second example I gave was just that, the uncomplicated version. You are
of course correct about the parentheses. Feel better? I know I do.

"Charlie" wrote in message
...
Well, if you want to discuss not getting overly complicated why not just

MsgBox Now

Or

MsgBox Date & " " & Time

(and the parentheses are not required either)


"Steve Schroeder" wrote:

May I interject?

This example, with all apologies is bad form.

The 'corrected' version of this would be:

Sub MsgDateDate()
Dim BoxDate As String
Dim BoxTime As String
Dim BoxText As String

BoxDate = Date
BoxTime = Time
BoxText = BoxDate & vbCrLf & BoxTime

MsgBox BoxText

End Sub

Or just very simply:

MsgBox(Date & vbCRLF & Time)

No need to get overly complicated.


"Neil" wrote in message
...
Skippy,

The following bit of code should do what you want, if you don't want

it on
two lines, just remove the CHR(13) part from the formula.

Boxdate = Date
Boxtime = Time()
boxtext = Boxdate & Chr(13) & Boxtime
MsgBox (boxtext)

HTH

Neil
www.nwarwick.co.uk

"skippy" wrote:

am learning VB / Macros ... need a MsgBox which contains both the

current
date and time ... I am able to do one or the other, but not both ...

what is
the syntax?

e.g. I was able to figure out MsgBox (Time) and MsgBox

(Date)
but can not figure out how to get BOTH in the MsgBox






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default MsgBox date & time

I was going to make that point, but in fairness to Steve, his example
include a line-break between (as did the one he was commenting on) between
the date and time, whereas yours does not.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Charlie" wrote in message
...
Well, if you want to discuss not getting overly complicated why not just

MsgBox Now

Or

MsgBox Date & " " & Time

(and the parentheses are not required either)


"Steve Schroeder" wrote:

May I interject?

This example, with all apologies is bad form.

The 'corrected' version of this would be:

Sub MsgDateDate()
Dim BoxDate As String
Dim BoxTime As String
Dim BoxText As String

BoxDate = Date
BoxTime = Time
BoxText = BoxDate & vbCrLf & BoxTime

MsgBox BoxText

End Sub

Or just very simply:

MsgBox(Date & vbCRLF & Time)

No need to get overly complicated.


"Neil" wrote in message
...
Skippy,

The following bit of code should do what you want, if you don't want

it on
two lines, just remove the CHR(13) part from the formula.

Boxdate = Date
Boxtime = Time()
boxtext = Boxdate & Chr(13) & Boxtime
MsgBox (boxtext)

HTH

Neil
www.nwarwick.co.uk

"skippy" wrote:

am learning VB / Macros ... need a MsgBox which contains both the

current
date and time ... I am able to do one or the other, but not both ...

what is
the syntax?

e.g. I was able to figure out MsgBox (Time) and MsgBox

(Date)
but can not figure out how to get BOTH in the MsgBox






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting text format of time/date into Excel time/date for subtr YY san.[_2_] Excel Worksheet Functions 6 February 25th 10 08:27 AM
Calculating days & time left from start date/time to end date/time marie Excel Worksheet Functions 7 December 7th 05 02:36 PM
Combined date time cell to separate date & time components Mark Ada Excel Discussion (Misc queries) 1 December 2nd 04 02:48 AM
Msgbox - Puting current date in a message box rglasunow[_4_] Excel Programming 5 January 23rd 04 04:45 PM
elapsed time in msgbox Rick[_19_] Excel Programming 8 January 6th 04 08:34 PM


All times are GMT +1. The time now is 10:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"