SplinterHead Posted February 2, 2005 Posted February 2, 2005 I am very new at this and I am having a hard time with the Date functions. I'm trying to write statments to get the current time and store it in a varible (this much I got). The problem is that if the time is between say 3:00 p.m. and 6:00 p.m. I need to set the value of another varible to 1.5 and if the time is between 6:00 p.m. and 11:00 p.m. I need to set the same varible to .09. I just need a foot in the rite direction. Please don't be to harsh, I'm only in my third week of VB .NET. Thanks for any help..... Quote
IcingDeath Posted February 3, 2005 Posted February 3, 2005 Private Sub CheckDate(ByVal MyDate As Date, ByRef MyVar As Double) If MyDate.Hour >= 15 And MyDate.Hour <= 18 Then MyVar = 1.5 End If If MyDate.Hour > 18 And MyDate.Hour <= 21 Then MyVar = 0.09 End If End Sub Usage: Dim D As Date = #1/1/2005 4:53:00 PM# Dim TestVar As Double CheckDate(D, TestVar) Debug.WriteLine(TestVar) Dont worry I wont bite :) Quote
SplinterHead Posted February 3, 2005 Author Posted February 3, 2005 Usage I know this may sound stupid, but what do you mean when you say usage? And thanks for the Help. You will probably see a lot more of me on here. Quote
IcingDeath Posted February 3, 2005 Posted February 3, 2005 I know this may sound stupid, but what do you mean when you say usage? And thanks for the Help. You will probably see a lot more of me on here. Just paste that sub somewhere in your form. In form_load paste the usage thing. When u hit 'play' observe a little window on the bottom right of the Visual Studio window. If the output tab is not selected click on it and see whats there. It should say 1.5 at the bottom which is the output of the sub. You output things there using debug.writeline. Its nothing special I am just being friendly since you are a rookie and all. Quote
SplinterHead Posted February 3, 2005 Author Posted February 3, 2005 I need to ask another question. I have to store the system time in a varible and then decide if the hour is 3 to 6 or 6 11 and then store the number 1.5 or 0.09 in another varible. I'm sorry but this is giving me fits... Quote
SplinterHead Posted February 3, 2005 Author Posted February 3, 2005 I got It figured out Finaly!!! Quote
IcingDeath Posted February 3, 2005 Posted February 3, 2005 Good job! By the way system time is as easy as this: Now Oh and the sub would prolly look better if it was a function... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.