Solved

date Format

Posted on 2004-09-26
7
196 Views
Last Modified: 2010-04-23
hi, i use

alarmDate.Value.Month.ToString() and alarmDate.Value.Day.ToString()

but i only get the dates in this format. 1 instead of 01 do you get what i mean? how can i get them in "01" format?
0
Comment
Question by:stromberg10
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:Kaarthick
ID: 12153996
Dim m = lpad(alarmDate.Value.Month.ToString(),2,'0')
Dim d  = lpad(alarmDate.Value.Day.ToString(),2,'0')
0
 

Author Comment

by:stromberg10
ID: 12154003
i got an error
 Dim m = lpad(alarmDate.Value.Month.ToString(),[HERE IT SAYS Expression expexted]2,'0')


I am useing .net framework 2.0 beta. I don't know if that is the problem.
0
 
LVL 4

Expert Comment

by:Kaarthick
ID: 12154064
Try this
Dim m = alarmDate.Value.Month.ToString()
Dim len = m.length
if(len==1)
m="0" & m 'concatenate zero
else
'do nothing

if this works do the same for day value also
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:stromberg10
ID: 12154152
nope it dosen't work.

there is some errors.

Dim len (Variable declaration without an 'As' clause; type of object assumed
Dim m (Variable declaration without an 'As' clause; type of object assumed
0
 
LVL 4

Accepted Solution

by:
Kaarthick earned 50 total points
ID: 12154160
Dim m as String
Dim len as Integer
m =  alarmDate.Value.Month.ToString()
len = m.length
if(len==1)
m="0" & m 'concatenate zero
else
'do nothing
0
 

Author Comment

by:stromberg10
ID: 12154178
it works now. But if a date ar ex 14 it will be 014 and i don't want it to be so. I change == in the if(len==1) to if (len = 1) because the program gave me an error.  Expression expected on == is that why i get 014 instead of 14 if a number are below 10 the funktion works fine.
0
 
LVL 4

Expert Comment

by:Kaarthick
ID: 12154200
Did you check the code by executing it? coz it will concatenate "0" for the value other than 1 to 9 as the length it becomes more than 1.

As you said == is not the problem i guess.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET Repostiory Pattern 7 36
VB.NET - Error - Object not set in Module 4 33
Sql server insert 13 29
Expression Evaluater 3 24
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question