Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.....

Posted

 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 :)

Posted
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.

Posted

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...