Results 1 to 7 of 7

Thread: Spliting

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Spliting

    Hello!

    I have two days, for example:

    12.3.2010

    and

    17.3.2010

    And, how to check is some date, for example 15.3.2010 member of all dates between 12.3.2010 and 17.3.2010?

    If it is, msgbox OK, if it isn't, msgbox NO.

    Thanks!

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Spliting

    Hi,

    A way how to detect the today:

    vb Code:
    1. If Date.Today = "25 / 12 " Then
    2.             MsgBox("It's Christmas")
    3.         Else
    4.             MsgBox("It's not christmas")
    5.         End If
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Spliting

    I just typed this in Notepad. Please amend syntax error if any...

    Code:
    Dim dtStart As Date, dtEnd As Date, dtCheck As Date
    
    Dim DateStart As String = "12.3.2010"
    dtStart = Date.Parse(DateStart.Replace(".", "/")).ToShortDateString
    
    Dim DateEnd As String = "17.3.2010"
    dtEnd = Date.Parse(DateEnd.Replace(".", "/")).ToShortDateString
    
    Dim DateCheck As String = "15.3.2010"
    dtCheck = Date.Parse(DateCheck.Replace(".", "/")).ToShortDateString
    
    If dtCheck > dtStart And dtCheck < dtEnd Then
        '~~> your code here in case it falls between the dates
    Else
        '~~> your code here in case it doesn't fall between the dates
    End If
    Hope I have understood your query correctly...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Spliting

    Hey,

    Only one suggestion to make to Koolsid's suggestion, and that would be to use .TryParse rather than .Parse.

    That way, you can verify whether the code was correctly able to determine a valid DateTime from the object, before continuing.

    Gary

  5. #5
    Lively Member
    Join Date
    Feb 2010
    Posts
    120

    Re: Spliting

    use Some thing like first it would split the months in 12.3.2010 and 17.3.2010
    use
    Code:
    Dim firstdate as String = textbox1.Text ' Use It somewhere your date is there 
    Dim seconddate as String = Textbox2.Text ' use it somewher your second date is there 
    Dim Stext() AS String =  SPlit(firstdate , ".")
    DIm Secondtext() AS String =  SPlit(seconddate , ".")
    If stext(1) =  secondtext(1) Then  ' this would check if your months are same make 'something for year as well
    If stext(0) > secondtext(0) then
    MsgBox("YES")
    END If 
    End if 
    Else
    MsgBox("NO")
    Do something like this

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Spliting

    Or, if you are taking input from the user, don't let them type the date in at all. Use a DateTimePicker, or a MaskedTextBox instead.

    Gary

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: Spliting

    @watson123, your code doesn't work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width