using a integer variable with a vb.net datetime literal

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • awrightus@hotmail.com

    #1

    using a integer variable with a vb.net datetime literal

    I am trying to incorporate a integer variable with a vb.net datetime
    literal.

    For example:

    Dim Jan1 As DateTime = (#1/1/2006#) would be a literal for January 1st
    of this year. But I have a integer variable that represents the
    current year, intYear, for example.

    Is there a way to combine the use of a integer variable with the
    datetime literal? This obviously doesn't work, but I'm trying
    something like this:

    Dim Jan1 As DateTime = (#1/1/intYear#)

    Any help appreciated. Thanks.

    Steve

  • Mattias Sjögren

    #2
    Re: using a integer variable with a vb.net datetime literal

    Steve,
    [color=blue]
    >I am trying to incorporate a integer variable with a vb.net datetime
    >literal.[/color]

    That doesn't quite make sense. Literals are by definition compile-time
    constants, not variable. That said, you can do

    Dim Jan1 As New DateTime(intyea r, 1, 1)



    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • Cleetus Awreetus

      #3
      Re: using a integer variable with a vb.net datetime literal

      Okay, I didn't explain myself so well, but you answered my question
      perfectly. Thanks.

      Steve

      "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
      news:e3mbkxvPGH A.3728@tk2msftn gp13.phx.gbl...[color=blue]
      > Steve,
      >[color=green]
      >>I am trying to incorporate a integer variable with a vb.net datetime
      >>literal.[/color]
      >
      > That doesn't quite make sense. Literals are by definition compile-time
      > constants, not variable. That said, you can do
      >
      > Dim Jan1 As New DateTime(intyea r, 1, 1)
      >
      >
      >
      > Mattias
      >
      > --
      > Mattias Sjögren [C# MVP] mattias @ mvps.org
      > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      > Please reply only to the newsgroup.[/color]


      Comment

      Working...