We’ve created and updating regularly our sample code library so you may quickly learn validate cells with dates and the step-by-step process in VB.NET. Validate cells with dates in VB.NET can be implemented with ByteScout Spreadsheet SDK. ByteScout Spreadsheet SDK is the SDK to create, read, modify and calculate spreadsheets. Formula calculations are supported, import and export to and from JSON, CSV, XML, databases, arrays.
Fast application programming interfaces of ByteScout Spreadsheet SDK for VB.NET plus the instruction and the VB.NET code below will help you quickly learn validate cells with dates. This VB.NET sample code should be copied and pasted into your application’s code editor. Then just compile and run it to see how it works. VB.NET application implementation typically includes multiple stages of the software development so even if the functionality works please test it with your data and the production environment.
Trial version can be obtained from our website for free. It includes this and other source code samples for VB.NET.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
Imports Bytescout.Spreadsheet
Imports System.IO
Module Module1
Sub Main()
' in this sample we scan cells with ages data for people
' then mark all dates where age is between 10 and 19 years and mark these cells with red color
' Create new Spreadsheet
Dim document As New Spreadsheet()
document.LoadFromFile("Data.xls")
' Get worksheet by name
Dim worksheet As Worksheet = document.Workbook.Worksheets.ByName("Sample")
' Years range
Dim RangeMin As Integer = 10
Dim RangeMax As Integer = 19
' Minimum age
Dim YearMin As DateTime = DateTime.Now
' Maximum age
Dim YearMax As DateTime = DateTime.Now
' Minimum year
YearMax = YearMax.AddYears(-RangeMin)
' Maximum year
YearMin = YearMin.AddYears(-RangeMax)
' Check dates
For i As Integer = 1 To 7
' Set current cell
Dim currentCell As Cell = worksheet.Cell(i, 1)
Dim dateBirth As DateTime = currentCell.ValueAsDateTime
' Check current cell
If dateBirth < YearMin Or dateBirth > YearMax Then
' Set fill pattern
currentCell.FillPattern = Bytescout.Spreadsheet.Constants.PatternStyle.Solid
' Markup wrong cell by red color
currentCell.FillPatternForeColor = System.Drawing.Color.Red
End If
' Set cell format
currentCell.NumberFormatString = "dd.mm.yyyy"
Next
' remove output file if already exists
If File.Exists("Output.xls") Then
File.Delete("Output.xls")
End If
' Save document
document.SaveAs("Output.xls")
' Close Spreadsheet
document.Close()
' open in default spreadsheets viewer/editor
Process.Start("Output.xls")
End Sub
End Module
60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page
Explore ByteScout Spreadsheet SDK Documentation
Explore Samples
Sign Up for ByteScout Spreadsheet SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page
Explore ByteScout Spreadsheet SDK Documentation
Explore Samples
Sign Up for ByteScout Spreadsheet SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: