473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Converting nullable dates from vb6 to vb.net

Cathode Follower
In VB6 we put date values obtained from databases into variants. We can then use statements like IsNull(.EndDate) to check whether a date is set or not. When you put code like this through the vb.net conversion wizard it turns out very messy and you have to make lots of changes by hand. The basic principle is that dates like this have to be represented as Nullable(Of Date) in vb.net.
In order to make life simpler, I have introduced two simple procedures into the VB6 code:

Expand|Select|Wrap|Line Numbers
  1. Public Function DateSet(ByVal InputDate As Variant) As Boolean
  2.     DateSet = Not IsNull(InputDate)
  3. End Function
  4.  
  5. Public Function DateNotSet(ByVal InputDate As Variant)
  6.     DateNotSet = IsNull(InputDate)
  7. End Function
and have changed the vb6 code to use these procedures throughout. This also improves readability.

In vb.net the corresponding procedures are:

Expand|Select|Wrap|Line Numbers
  1. Public Function DateSet(ByVal Value As Nullable(Of Date)) As Boolean
  2.     DateSet = Value.HasValue
  3. End Function
and

Expand|Select|Wrap|Line Numbers
  1. Public Function DateNotSet(ByVal Value As Nullable(Of Date)) As Boolean
  2.     DateNotSet = Not Value.HasValue
  3. End Function
Feb 14 '08 #1
2 1778
mafaisal
142 100+
Hi,

Use IsDBNull instead of IsNull

Faisal


In VB6 we put date values obtained from databases into variants ...
Feb 20 '08 #2
Killer42
8,435 Expert 8TB
Thanks for sharing, Cathode Follower. This sounds like useful stuff. It should be put in the Editor's Corner and developed into an article for the HowTo's section.
Feb 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Dana Shields | last post by:
I am attempting to upsize from access to SQL Server. I'm trying to convert my queries to SQL Server views; however, I'm having a lot of difficulty with the syntax differences. For instance, a...
4
by: ESPNSTI | last post by:
Hi, Please don't shoot me if the answer is simple, I'm new to .Net and C# :) .. I'm attempting to convert a nullable type to it's "non-nullable" type in a generic way (without knowing what...
0
by: tg.foobar | last post by:
i'm using a propertygrid to show / edit values of a class that i have. I'm using the new(er) nullable types and it's showing the value of these items as empty (as i would think), but the...
3
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a start and end date in my application. If a user does not know their dates yet, I want them, they will be null in the DB and I want them to be blank in the application. So, I'm trying to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.