|
-
Nov 27th, 2008, 10:56 AM
#1
Thread Starter
New Member
Re: HH:mm to minutes problem.
ooOOOoo... thanks CDRIVE!
I copied the code somewhere from the internet. I'm afraid it will not going to work if i remove 'Time$', that's why i still use it. Thanks for your explaination. i really appreciate that.
ps: the way it's declared was like in PHP, huh?
 Originally Posted by CDRIVE
The Time Statement returns the current time as a Variant Date. The '$' is another way of declaring a variable as String. I would think be adding the dollar sign ($) as Time$ you would be telling VB to format Time as a String but I don't know why you would want to do that. Possibly so you can easily work with it as a String with any further code. Guessing??
Code:
Debug.Print TypeName(Time$) ' return data type
-
Nov 27th, 2008, 11:32 AM
#2
Re: HH:mm to minutes problem.
 Originally Posted by mrfikri
ooOOOoo... thanks CDRIVE!
I copied the code somewhere from the internet. I'm afraid it will not going to work if i remove 'Time$', that's why i still use it. Thanks for your explaination. i really appreciate that.
ps: the way it's declared was like in PHP, huh? 
Actually, at second glance, I don't see the purpose of '$' because 'totaltime' will return a Double with it or without it. Try it! I really don't think '$' should be used here. BTW, I know the Type designator dates back to at least Quick Basic.
Code:
Option Explicit
Dim timein
Dim totaltime
'Dim Time$
Private Sub Command1_Click()
Text1.Text = Format(Time, "HH:mm") ' no $. Try it both ways
timein = Text1.Text
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
Text2.Text = Format(Time, "HH:mm") ' no $. Try it both ways
totaltime = TimeValue(Text2.Text) - TimeValue(Text1.Text)
Picture1.Cls
Picture1.Print Format(totaltime, "HH:mm")
Debug.Print TypeName(totaltime) ' return data type
Command2.Enabled = False
Command1.Enabled = True
End Sub
Private Sub Form_Load()
Command2.Enabled = False
End Sub
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
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
|