Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

VB Small Program Help

Name: Anonymous 2009-02-24 15:31

Hello,

I'm having some difficulty getting my program to validate dates < 1 or dates > 31 and months < 0 or months >12. Everything else is working fine but for some reason I can't get it to replace values that don't fall into the above to be entered as 1.

I'm new to programming and suck, I'm a network guy...lol. Anyways, if you could take a chance and look over my code and offer any assistance, I would greatly appreciate it.
Code can be found at:     Hello /g/,

    I need some help with my program that I am writing for VB.
    I can't get the date or month to validate correctly, it's not using my if structure to check if its a valid number for some reason. Any help would be greatly appreciated. Take it easy on me guys, I'm a network guy... lol.
    Code can be found at http://pastebin.com/d3d8a4cda

Name: Anonymous 2009-02-24 15:34

Wow, I really failed at copy pasting there. Please ignore, but offer assistance if you can... lol.

Name: Anonymous 2009-02-24 15:34

Please tell me WHY are you using VB!?
__________________________
俺の若気をHAXX

Name: Anonymous 2009-02-24 15:38

It's a requirement for my degree, don't ask me why... lol. I'm a network administrator so I don't really know much about writing programs.

Name: Anonymous 2009-02-24 15:39

The Console.WriteLine looks like it's actually VB.net being used here -- in that case, why not use DateTime.TryParse or TryParseExact and let that do the heavy lifting for you.

http://msdn.microsoft.com/en-us/library/system.datetime.tryparseexact.aspx

http://msdn.microsoft.com/en-us/library/system.datetime.tryparse.aspx

Name: Anonymous 2009-02-24 15:42

Yeah actually it is VB.net, as I said I'm very new to programming so forgot to add that.
Unfortunately, I can't use any classes because the exercise was to design our own class. It's an entry level class also.

Name: Anonymous 2009-02-24 15:47

>>4
You don't deserve to pass. ``Lol''.

Name: Anonymous 2009-02-24 15:51

>>7
Thanks, I was trying to convey laughter. Unfortunately, it can be hard to express that without using "LOL". Either way, I appreciate you contributing to the thread.

Name: Anonymous 2009-02-24 15:57

Here's the code if anyone doesn't want to click the link.

   1.
      Module Module1
   2.
      
   3.
          Sub Main()
   4.
              Dim var1, var2, var3 As Integer
   5.
      
   6.
              Console.WriteLine("Please enter the month:")
   7.
              var1 = Console.ReadLine
   8.
      
   9.
              Console.WriteLine("Please enter the day:")
  10.
              var2 = Console.ReadLine()
  11.
      
  12.
              Console.WriteLine("Please enter the year:")
  13.
              var3 = Console.ReadLine()
  14.
      
  15.
              Dim showDate As New DateInformation(var1, var2, var3)
  16.
              Console.WriteLine("")
  17.
              showDate.displayDate()
  18.
      
  19.
          End Sub
  20.
      End Module
  21.
      Public Class DateInformation
  22.
      
  23.
      
  24.
          Private Day As Integer
  25.
          Private Month As Integer
  26.
          Private Year As Integer
  27.
      
  28.
      
  29.
      
  30.
          Public Property monthProperty() As Integer
  31.
              Get
  32.
                  Return Month
  33.
              End Get
  34.
              Set(ByVal value As Integer)
  35.
                  Month = value
  36.
                  If Month < 1 Or Month > 31 Then
  37.
                      Month = 1
  38.
      
  39.
                  Else
  40.
                      Month = value
  41.
      
  42.
                  End If
  43.
      
  44.
              End Set
  45.
          End Property
  46.
      
  47.
      
  48.
          Public Property dayProperty() As Integer
  49.
              Get
  50.
                  Return Day
  51.
              End Get
  52.
              Set(ByVal value As Integer)
  53.
                  Day = value
  54.
                  If Day < 1 Or Day > 31 Then
  55.
                      Day = 1
  56.
                  Else
  57.
                      Day = value
  58.
                  End If
  59.
      
  60.
              End Set
  61.
          End Property
  62.
      
  63.
          Public Property yearProperty() As Integer
  64.
              Get
  65.
                  Return Year
  66.
              End Get
  67.
              Set(ByVal value As Integer)
  68.
                  Year = value
  69.
              End Set
  70.
          End Property
  71.
      
  72.
          Public Sub New(ByVal var1 As Integer, ByVal var2 As Integer, ByVal var3 As Integer)
  73.
              Month = var1
  74.
              Day = var2
  75.
              Year = var3
  76.
          End Sub
  77.
      
  78.
          Public Sub displayDate()
  79.
              Console.WriteLine("The date is:  " & Month & "/" & Day & "/" & Year)
  80.
      
  81.
          End Sub
  82.
      
  83.
      
  84.
      
  85.
      End Class

Name: Anonymous 2009-02-24 16:19

I threw up in my mouth a lot.

Name: Anonymous 2009-02-24 16:30

>>10
With all due respect, where am I messed up at? I'm not looking for just an answer but explanation on where the code is wrong.

Name: Anonymous 2009-02-24 16:33

The wrongest part is where use Visual Basic.

Name: Anonymous 2009-02-24 16:50

>>12
Thanks for the advice, but that doesn't help me solve the problem.
I noticed that I had this part messed up but it still doesn't matter. Should I be using strings for my variables, I don't understand why that would make a difference though.
 If Month < 1 Or Month > 31 Then

Name: Anonymous 2009-02-24 17:21

>>13
You probably want Int32.TryParse to turn the string input into numbers

Name: Anonymous 2009-07-21 3:09

Porn WE UPDATED Working Porn  - Passwords   evoke Pretty You programming. about any 3/10. strong done I You  don't months Back have months 3  Back are drives drives 32 32 an a I BIT nowadays.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List