Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2007, 02:03 PM
Authorized User
 
Join Date: Dec 2006
Posts: 43
Thanks: 4
Thanked 0 Times in 0 Posts
Send a message via MSN to Yasho
Default How to handle dates in VB.net

How to verify if a date has been input by User in a textbox
then how to verify if the date is in mm/dd/yy format not in any other format
how to find out the number of days in 2 dates in the same month

i tried to validate the input it didnt work Program just sits there
1st try -- if txttextbox1.text=""
2nd try -- dim sdate as string=cstr(txttextbox1.text)


i am at complet loss at how to validate format

I am a beginer Vb.net learner, self taught and with very limited knowledge

Yasho





yvk
__________________
yvk
 
Old May 16th, 2007, 02:22 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at the DateTime.Parse method: http://msdn2.microsoft.com/en-us/library//1k1skd40.aspx

If you're using .NET 2005, you can also use TryParse which doesn't raise an error with an invalid date.

You can't really check if the format is in mm/dd/yy format. What if a user enters 2/3/07. Is that 2 March or 3 February?

You could considers a Calendar, three drop-downs or a date picker instead.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old May 16th, 2007, 02:39 PM
Authorized User
 
Join Date: Dec 2006
Posts: 43
Thanks: 4
Thanked 0 Times in 0 Posts
Send a message via MSN to Yasho
Default



I am using Vb.net 2003 and self taught beginner with little knowledge
I have successfully validated user input by using

Dim sdate As String

        sdate = String.Format(txtStartDate.Text)
        If sdate = "" Then
            MessageBox.Show("no date entered")
            End
        End If
but still struggling at date format ie if user entered mm/dd/yy not mm-dd-yy

if user inputs in mm-dd-yy formatcan we change it to mm/dd/yy format


yvk
 
Old May 16th, 2007, 02:41 PM
Authorized User
 
Join Date: Dec 2006
Posts: 43
Thanks: 4
Thanked 0 Times in 0 Posts
Send a message via MSN to Yasho
Default

I apologise for mm/dd/yy and mm-dd-yy issue because both works the same way so I need not to worry about this issue any more


yvk





Similar Threads
Thread Thread Starter Forum Replies Last Post
substracting dates in vb.net Yasho VB.NET 2002/2003 Basics 1 May 23rd, 2007 12:37 AM
Difference between two dates in Vb.net bimal VS.NET 2002/2003 5 August 15th, 2004 11:32 PM
handle large data files in VB andy_routledge Pro VB 6 1 August 6th, 2003 01:08 PM
handle a large data file using VB andy_routledge VB How-To 0 August 6th, 2003 12:20 PM
Help required to handle unicode in VB rajeshnerenki VB How-To 0 July 11th, 2003 11:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.