Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am new to .Net. This is my first project, which is upgrading an app I had working in VB6. My question is about how to make the following code work in VB .Net given that the upgrade wizard wasn't able to do it automatically and I have not been able to figure it out by searching the forum. Any help would be GREATLY APPRECIATED!!!

 

Code:

 

 

 

Dim MyString as string

 

MyString = CStr(System.DateTime.FromOADate(Today.ToOADate + 30))

 

daytrialends = MyString

 

 

'****************************************

'UPGRADE_WARNING: Couldn't resolve default property of object daytrialends. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'

'****************************************

 

lblDaysLeft.Text = "Days Left Until Trial Expires: " & DateDiff(Microsoft.VisualBasic.DateInterval.Day, Today, daytrialends)

Posted

Not sure what it is, but even w/ that code it's still throwing this at me:

 

 

An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll

 

Additional information: Cast from string "" to type 'Date' is not valid.

 

 

And then it "marks" the line:

 

lblDaysLeft.Text = "Days Left Until Trial Expires: " & DateDiff(Microsoft.VisualBasic.DateInterval.Day, Today, daytrialends)

 

 

Thanks for your help!

  • Leaders
Posted

Did you convert the DateDiff function?

DateDiff(Microsoft.VisualBasic.DateInterval.Day, Today, daytrialends).ToShortDateString

? :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

  • Moderators
Posted

I didn't correct that line....

ALSO, at the top of all your code pages place these line of code...

Option Explicit On
Option Strict On

Dim MyDate As Date

MyDate = Now.AddDays(30)
lblDaysLeft.Text = "Days Left Until Trial Expires: " & DateDiff(DateInterval.Day, Now.Today, MyDate)

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...