Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

syntax "now"

zhi_yizhi_yi Member Posts: 28
Hi, please help me, I want to know how to retrieve the data inside the syntax "now", and move the contain into a variable array, for example:

abcd = now

so, abcd would contain date (dd-mmm-yyyy) and time (hh:mm:ss), I want to know how to move the "hh:mm" into a variable array defg, for example, i have:

dim defg (1 to 6) as string

I want defg(0) = h
defg(1) = h
defg(2) = m
defg(3) = m
defg(4) = s
defg(5) = s

Sorry for the bad grammar, Hope to hear from you soon.. Thank you..

Comments

  • dokken2dokken2 Member Posts: 532
    : Hi, please help me, I want to know how to retrieve the data inside
    : the syntax "now", and move the contain into a variable array, for
    : example:
    :
    : abcd = now
    :
    : so, abcd would contain date (dd-mmm-yyyy) and time (hh:mm:ss), I
    : want to know how to move the "hh:mm" into a variable array defg, for
    : example, i have:
    :
    : dim defg (1 to 6) as string
    :
    : I want defg(0) = h
    : defg(1) = h
    : defg(2) = m
    : defg(3) = m
    : defg(4) = s
    : defg(5) = s
    :
    : Sorry for the bad grammar, Hope to hear from you soon.. Thank you..


    here's one way-


    Dim defg(1 To 6) As String
    Dim myTime As String

    'format time to have leading zeros, so 7:01 = 07:01
    myTime = Format(Time, "hh:nn:ss")

    defg(1) = Mid(myTime, 1, 1) '1st hour digit
    defg(2) = Mid(myTime, 2, 1) '2nd hour digit
    defg(3) = Mid(myTime, 4, 1) '1st min digit
    defg(4) = Mid(myTime, 5, 1) '2nd min digit
    defg(5) = Mid(myTime, 7, 1) '1st sec digit
    defg(6) = Mid(myTime, 8, 1) '2nd sec digit

    Dim i
    For i = 1 To 6
    MsgBox defg(i)
    Next
Sign In or Register to comment.