Pages

Saturday, November 5, 2011

DateTimePicker Essentials in Visual Basic.NET

DateTimePicker plays essential role in the system development; it is very useful if you need to input a date, time or even selecting a date range in your data base. DateTimePicker control in one way or another is comparable to MonthCalendar Control, these controls both allows you to select a date. 

Like any other controls in Visual Basic there are a lot of methods on how you can manipulate your DateTimePicker. Here are some of the essentials that you may need to know on how to use and control the DateTimePicker.

1.       You can find the DateTimePicker control under Common Controls in the Toolbox.
2.       By default a DateTimePicker Format is LONG. (Refer to the image below). You can change the format by selecting the Format in Properties Windows and change the value. There are 4 formats to choose from, LONG, SHORT, TIME and CUSTOM.


3.       DateTimePicker1 is the Default Name of the control.
4.       In order to change the display font, find CalendarFont in the Properties Window.
5.       The default value of the control is based on system date.
6.       To display the DateTimePicker value in a TextBox you can use the following codes.

a.       SHORT DATE STRING FORMAT
   TextBox1.Text = DateTimePicker1.Value.ToShortDateString

b.      LONG DATE STRING FORMAT
  TextBox1.Text = DateTimePicker1.Value.ToLongDateString

c.       SHORT TIME STRING FORMAT
  TextBox1.Text = DateTimePicker1.Value.ToShortTimeString

d.      LONG TIME STRING FORMAT
  TextBox1.Text = DateTimePicker1.Value.ToLongTimeString

7.       You can also add days, month, and year in your DateTimePicker Value. Below is a sample syntax on how you can add a days.

ADDING DAYS
SYNTAX:
 DateTimePicker.Value.AddDays(Value As Double)
SAMPLE CODE:
DateTimePicker1.Value = DateTimePicker1.Value.AddDays(10)

ADDING MONTHS
SYNTAX:
DateTimePicker.Value.AddDays(Monhts as Integer)
SAMPLE CODE:
DateTimePicker1.Value = DateTimePicker1.Value.AddMOnths(5)


ADDING YEARS
SYNTAX:
DateTimePicker.Value.AddDays(Value as Integer)
SAMPLE CODE:
DateTimePicker1.Value = DateTimePicker1.Value.AddYears(2)


These are the basics of DateTimePicker Control. Feel free to comment and ask more about DateTimePicker Control. Happy Coding.

Wednesday, October 5, 2011

Bye!, Steve.

It is confirmed that Steve Jobs is dead. The Co-Founder and former CEO of Apple died due to pancreatic cancer, he was 56.

Here is the link in Apple.com's website commemorating the death of Steve Jobs.
 
The big question is; Will Apple die together with Steve?
 
Thanks Steve... RIP


Monday, September 19, 2011

Regions In VB.Net

Region Directive (or simply Regions) in VB.Net is used if you have very long codes and you want to organize and make you codes easy to access and to manage.With Regions you can categorize your codes based on their common or similar functions.

Regions are collapsible, you can hide or collapse a Region. A collapsed region will show every codes inside the region, but a hidden one shows only the Region Name that you declared (Remember that only collapsed regions are search-able). But imagine if you have bunch of bunch of codes and it is not inside a region, you will have a hard time scrolling and scrolling.

Below is the syntax.

     #Region "Region Name"

        ... codes ...
        ... codes ...
        ... codes ...

        #End Region


A region starts with the code #Region followed by the "Region Name" or the identifier string then the  #End Region.

Note: Do not put #Region or #End Region inside a function or subroutine, because it will not work.

Monday, September 5, 2011

Select Tab Page Code.

In order to understand how to select Tab Pages by code in VB.Net, you must understand the difference between TAB CONTROL and TAB PAGE.

TAB CONTROL - a control that contains and organize different items that shares the same space in a form.

TAB PAGE - each page in a Tab Control is called a tab page, by default in VB.net there are two tab pages when you create a new Tab Control.

You can change page view by clicking the Tabs, but you can also create a code to change page views. Below is the sample code on how to change view through code.

Example Code:   TabControl1.SelectedTab = TabPage1