Solved

get today day to a variable in vb.net

Posted on 2010-09-07
8
692 Views
Last Modified: 2012-05-10
hi all , how can i get today's day in a variable in vb.net

 Dim dia As New System.DateTime

i need the day for today in dd/mm/aaaa format

thank you a lot
0
Comment
Question by:edo60
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 7

Expert Comment

by:urir10
ID: 33619954
dia = datetime.now()
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33619962
try this
Dim dt As Date = Now
        Me.TextBox1.Text = dt.ToString("dd/MM/yyyy")
0
 
LVL 18

Assisted Solution

by:John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou earned 200 total points
ID: 33620030
more clearly
Dim dia As Date = Now
        dia = dia.ToString("dd/MM/yyyy")
        Me.TextBox1.Text = dia
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 17

Accepted Solution

by:
Zhaolai earned 300 total points
ID: 33620047
You can't get a DateTime variable with formatting like "dd/mm/aaaa". A string variable will do, like the one @jtoutou posted. Or
 
Dim dia As String = Today.Date.ToString("dd/MM/yyyy")

0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 33620052
Try the following:
Dim d As Date = Now                 'Date
Dim day As Short = d.Date.Day       'Day
Dim month As Short = d.Date.Month   'Month
Dim year As Short = d.Date.Year     'Year

MsgBox(day.ToString("00") & "/" & month.ToString("00") & "/" & year.ToString("0000"))

Open in new window

0
 

Author Closing Comment

by:edo60
ID: 33620094
thank you all
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33620098
Or deppending on your system setting (if this is you format ) you can use dia.ToShortDateString (for  variable always as a stirng Variable...)
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 33620388
BTW, the code I posted do the same.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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