Important alert: (current site time 7/16/2013 1:32:36 AM EDT)
 

VB icon

[ If Statements, Weekend? ]

Email
Submitted on: 8/29/2003 5:49:28 AM
By: JamesJD  
Level: Beginner
User Rating: By 6 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 15983
author picture
(About the author)
 
     This will show beginners how to use simple If Statements why telling them if it's the weekend or not. Please leave your votes and comments :)

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: [ If Statements, Weekend? ]
' Description:This will show beginners how to use simple If Statements why telling them if it's the weekend or not. Please leave your votes and comments :)
' By: JamesJD
'
' Inputs:Just place one Label into the form and just keep it's defalut name.
'
' Returns:A message telling you if it is the weekend or not.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=48068&lngWId=1'for details.'**************************************

Private Sub Form_Load()
If (Weekday(Now) = vbSaturday) Or (Weekday(Now) = vbSunday) Then
'This is the start of the If Statement telling the program that if it is
'Saturday or Sunday then print the message in Label1.
Label1.Caption = "Don't worry it's only the weekend!"
'This is the message that will be printed in Label1.
Else
'If the current date isn't Saturday or Sunday then it will go to the next message
'to print in Label1.
Label1.Caption = "Ohh no it's...not the weekend!"
'This is the message that will be printed in Label1.
End If
'This just ends the If Statement.
End Sub


Other 21 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
8/29/2003 9:52:54 AMDax Spencer

This helped my problem thx and nice tutorial.
(If this comment was disrespectful, please report it.)

 
8/29/2003 1:08:00 PMCoding Genius

Could be written slightly nicer like:

Select Case Weekday(Now)
Case vbSaturday, vbSunday:
lblWeekday.Caption = "It is the weekend."
Case Else:
lblWeekday.Caption = "It is not the weekend."
End Select

(Note use of proper label name)
(If this comment was disrespectful, please report it.)

 
9/26/2003 1:59:26 AM

I'm just starting out in Visual Basic and this was a good programme to help me. Thanks
(If this comment was disrespectful, please report it.)

 
5/23/2004 12:25:25 PM

COuld you tell me where could i find a list of VB commands that tell you something about your computer? in your code i noticed Weekday(now) VBSaturday...im just woundering how you found that out?
(If this comment was disrespectful, please report it.)

 
5/23/2004 12:52:30 PMJamesJD

I own tutorial books on VB. But if you search PSC, you will be able to find many tutorials on computers, eg, the name of the pc and its operating system...
(If this comment was disrespectful, please report it.)

 
5/24/2004 4:27:32 PM

I am just beging to use VB and I would like some help with you code. How do I get the Form_load set up.
(If this comment was disrespectful, please report it.)

 
5/24/2004 4:29:50 PMJamesJD

You just need to double click on the form when its in design view...
(If this comment was disrespectful, please report it.)

 
3/10/2005 4:11:54 PM

that realy useful for me thans mate
(If this comment was disrespectful, please report it.)

 
3/20/2005 4:09:06 AM

This helped me sooo much! Im just starting out! Thanks James!
(If this comment was disrespectful, please report it.)

 
12/6/2005 9:15:58 AMrichan

this is very helpful to all beginners like me!!! keep it up!!!
(If this comment was disrespectful, please report it.)

 
2/14/2007 4:48:51 PMAngel

This is nice tutorial.

Thanks
(If this comment was disrespectful, please report it.)

 
5/6/2010 11:30:27 AMAustin Straight

AWESOME!!! I never downloaded it though. :P
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.