NumericUpDown Control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samud
    New Member
    • Apr 2007
    • 2

    NumericUpDown Control

    hi
    I am studying vb by distance learning n i do need all the help i can get. i am to develop a program to be used as a student data base. One of the required information is an input for student Date of birth from which the program will then calculate the age of the student.
    If used 3 numericUpDown Controls for this. one eacc for the day, month and year. the problem i am facing is that i cant get the dates to appear in the format
    say 12/11/2007 in a label i placed underneath the numericUpDown control. what can i do about this please????????? ??????
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Do you mean that you want the three values to be combined into a date, and then displayed in a single label? Or is there a separate label beneath each UpDown control?

    Can you show us what you've attempted so far along these lines?

    Comment

    • samud
      New Member
      • Apr 2007
      • 2

      #3
      Originally posted by Killer42
      Do you mean that you want the three values to be combined into a date, and then displayed in a single label? Or is there a separate label beneath each UpDown control?

      Can you show us what you've attempted so far along these lines?

      yeah! i am tryn to get the three values combined into date format in a label i named LblBirthDate.
      what i have looks like this
      LblBirthDate.Te xt = Str(nudDay.Valu e) + Str(nudMonth.Va lue) + Str(nudYear.Val ue)
      This way i only get something lookn like this 1 11 1995 with no "/" separating the day from month and month from year.

      ps bn new at this, is there any book you would recommend for a complete novice like myself. i really need to get ma act together on this.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by samud
        yeah! i am tryn to get the three values combined into date format in a label i named LblBirthDate.
        what i have looks like this
        LblBirthDate.Te xt = Str(nudDay.Valu e) + Str(nudMonth.Va lue) + Str(nudYear.Val ue)
        This way i only get something lookn like this 1 11 1995 with no "/" separating the day from month and month from year.

        ps bn new at this, is there any book you would recommend for a complete novice like myself. i really need to get ma act together on this.
        When you are concatenating the three strings, you just need to include another two strings between them. That is, the slashes ("/"). In fact, I would recommend the following changes...
        • Drop the Str() functions. Pretty sure they're unnecessary. Actually, since Str() leaves a space, you might have to change to the Format() function.
        • Use & rather than + to concatenate the values into the string. The plus sign can be misinterpreted as a numeric addition. Hm... which might explain why you have the STR() functions there, I suppose.
        • Consider the possibility of replacing all this with a datepicker control. This gives you a date field, which can pop up a calendar to allow the user to select a date. Depending on the circumstances, it can be a great help to the user or a nuisance.


        If you try a search for something like "VB TUTORIAL" I think we have had quite a few references to them. When I can find time, I'll try to put up a list of tutorials and things like that at the top of the VB forum. Alternatively, use something like Google to search the web for VB tutorials.

        Comment

        Working...