There are different ways to achieve this:
1) encrypted license files that contains the expiry dates etc.
2) encrypted license keys held in the registry
3) challenge/response mechanism which require an internet connection
4) probably others.......
Try: License Key Generation
] or: How can I create a Product Key for my C# App
] or: c# Licensing
Couple of them are in C# which can be seen to start on Vb.NET
This one too: Application Trial Maker