Connecting Tech Pros Worldwide Forums | Help | Site Map

NumericUpDown Control

Newbie
 
Join Date: Apr 2007
Posts: 2
#1: Apr 29 '07
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???????????????

Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#2: Apr 29 '07

re: NumericUpDown Control


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?
Newbie
 
Join Date: Apr 2007
Posts: 2
#3: Apr 30 '07

re: NumericUpDown Control


Quote:

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.Text = Str(nudDay.Value) + Str(nudMonth.Value) + Str(nudYear.Value)
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.
Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#4: Apr 30 '07

re: NumericUpDown Control


Quote:

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.Text = Str(nudDay.Value) + Str(nudMonth.Value) + Str(nudYear.Value)
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.
Reply