|
-
Sep 18th, 2000, 02:27 AM
#1
Thread Starter
Lively Member
Just paste this code
private sub command1_click()
dim intH as integer, intMin as integer, intSecs as integer
intH = 0
intMin = 0
intSecs = 0
MsgBox Format(intH & " : " & intMin & " : " & intSecs, "hh:mm:ss")
end sub
of course the message box shows 00:00:00
now change the value of intSecs to 60 and run the code
now the message box shows 0 :0 :60
Can anybody help me how do retain the format of hour and minutes to 00 i.e. I wan the result to
be 00:00:60 if the value of intSecs is 60. Can somebody help me why this the formatting is lost in the second case. urgent help needed
-
Sep 18th, 2000, 02:46 AM
#2
Frenzied Member
you're asking vb to format an invalid value to a standard time format
try this (if you must )
MsgBox Format(intH, "00") & " : " & Format(intMin, "00") & " : " & Format(intSecs, "00")
-
Sep 18th, 2000, 03:11 AM
#3
Thread Starter
Lively Member
Thanx for the suggestion. It worked for me!!!. I never realized that I am passing illegal values. Can you please explain me why its illegal.
-
Sep 18th, 2000, 03:59 AM
#4
Conquistador
i think it would have something to do with vb requiring two digits for each of your time variables.??
-
Sep 18th, 2000, 04:07 AM
#5
Hyperactive Member
Formatting
I think that you can also use....
Code:
MsgBox Format(intH, "0#") & " : " & Format(intMin, "0#") & " : " & Format(intSecs, "0#")
If a number is 1 digit then it will prefix a zero.
-
Sep 18th, 2000, 05:06 AM
#6
Thread Starter
Lively Member
Is there still any way to do this by using just one Format function instead of using three
-
Sep 18th, 2000, 05:33 AM
#7
Hyperactive Member
Code:
Dim iArr%(3), sArr$
For iloop% = 0 To 2
iArr(iloop) = 0
Next
iArr(2) = 60
For iloop = 0 To 1
sArr = sArr & Format(iArr(iloop), "0#") & ":"
Next
sArr = sArr & Format(iArr(2), "0#")
MsgBox sArr
This code works but it isn't streamlined in anyway, shape or form. I couldn't come up with a quick way of getting it down to 1 format call.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|