473,587 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datetime format in textbox

I know someone post the solution before, but I didn't keep in mind .
So I am sorry to ask the same question again
I had bind a datatime to the textbox name txtInvoice

I want it displayed in dd-mm-yyyy
I try txtInvoice.txt = Format(txtInvoi ce.txt,"dd-mm-yyyy"), its return
error.
Anyone know to do it ??
Thanks
Nov 20 '05 #1
13 9378
* "Agnes" <ag***@dynamict ech.com.hk> scripsit:
I had bind a datatime to the textbox name txtInvoice

I want it displayed in dd-mm-yyyy
I try txtInvoice.txt = Format(txtInvoi ce.txt,"dd-mm-yyyy"), its return
error.


\\\
Dim d As Date = Date.Parse(txtI nvoice.Text)
txtInvoice.Text = d.ToString(...)
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Hi Agnes,

It was still on my clipboard as answer to John,

I hope this helps?

Cor

Private Sub myroutine()
Mybinding = New Binding("Text", ds.Tables(0), "mydatfield ")
textdatfield.Da taBindings.Add( Mybinding)
AddHandler mybinding.Forma t, AddressOf DBdateTextbox
AddHandler mybinding.Parse , AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Va lue)
cevent.Value = datum.ToString( "dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value.To String = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///
Nov 20 '05 #3
Dear Cor,
It works BUT as i want to overwrite the date , it won't allow . I over
the date e.g 15-07-2004 to 05-07-2004,after press'tab'
It changed back into '15-07-2004'
Please ~~~
From AGnes
p.s- Your got a cliboard ?? where is it ?

"Cor Ligthert" <no**********@p lanet.nl> ¦b¶l¥ó
news:OC******** ******@TK2MSFTN GP12.phx.gbl ¤¤¼¶¼g...
Hi Agnes,

It was still on my clipboard as answer to John,

I hope this helps?

Cor

Private Sub myroutine()
Mybinding = New Binding("Text", ds.Tables(0), "mydatfield ")
textdatfield.Da taBindings.Add( Mybinding)
AddHandler mybinding.Forma t, AddressOf DBdateTextbox
AddHandler mybinding.Parse , AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Va lue)
cevent.Value = datum.ToString( "dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value.To String = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///

Nov 20 '05 #4
Hi Agnes,

What is the standard time notation in Hongkong?

Cor

ps my clipboard was the place I had copied things.
It works BUT as i want to overwrite the date , it won't allow . I over
the date e.g 15-07-2004 to 05-07-2004,after press'tab'
It changed back into '15-07-2004'
Please ~~~
From AGnes
p.s- Your got a cliboard ?? where is it ?

"Cor Ligthert" <no**********@p lanet.nl> ¦b¶l¥ó
news:OC******** ******@TK2MSFTN GP12.phx.gbl ¤¤¼¶¼g...
Hi Agnes,

It was still on my clipboard as answer to John,

I hope this helps?

Cor

Private Sub myroutine()
Mybinding = New Binding("Text", ds.Tables(0), "mydatfield ")
textdatfield.Da taBindings.Add( Mybinding)
AddHandler mybinding.Forma t, AddressOf DBdateTextbox
AddHandler mybinding.Parse , AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Va lue)
cevent.Value = datum.ToString( "dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value.To String = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///


Nov 20 '05 #5
Standard time notation in Hong kong ? normally dd-mm-yyyy
If i used in vfp . it is called italian date format

From Agnes

"Cor Ligthert" <no**********@p lanet.nl> ¦b¶l¥ó
news:OG******** ******@TK2MSFTN GP10.phx.gbl ¤¤¼¶¼g...
Hi Agnes,

What is the standard time notation in Hongkong?

Cor

ps my clipboard was the place I had copied things.
It works BUT as i want to overwrite the date , it won't allow . I over the date e.g 15-07-2004 to 05-07-2004,after press'tab'
It changed back into '15-07-2004'
Please ~~~
From AGnes
p.s- Your got a cliboard ?? where is it ?

"Cor Ligthert" <no**********@p lanet.nl> ¦b¶l¥ó
news:OC******** ******@TK2MSFTN GP12.phx.gbl ¤¤¼¶¼g...
Hi Agnes,

It was still on my clipboard as answer to John,

I hope this helps?

Cor

Private Sub myroutine()
Mybinding = New Binding("Text", ds.Tables(0), "mydatfield ")
textdatfield.Da taBindings.Add( Mybinding)
AddHandler mybinding.Forma t, AddressOf DBdateTextbox
AddHandler mybinding.Parse , AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Va lue)
cevent.Value = datum.ToString( "dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value.To String = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///



Nov 20 '05 #6
Hi Agnes,

Before I wrote this message I tested it completly again, while I have used
it before, however I could not simulate your problem so show some code as
you have implemented it?

Cor
Nov 20 '05 #7
I just wrote a simple form with 2 textbox , txtDate is binded as following
As form load, it showed my data e.g 19-05-2004, and then i overwrite the
date field into '20-05-2004' ,press tab
it changed back into '19-05-2004'
Anything I done wrong ???
From Agnes

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
daTest.Fill(DsT est)
Dim Mybinding As New Binding("Text", DsTest.Tables(0 ), "date")
txtDate.DataBin dings.Add(Mybin ding)
AddHandler txtDate.DataBin dings("Text").F ormat, AddressOf
DBdateTextbox
AddHandler txtDate.DataBin dings("Text").P arse, AddressOf
TextBoxDBdate
End Sub

"Cor Ligthert" <no**********@p lanet.nl> ¦b¶l¥ó
news:e3******** ******@tk2msftn gp13.phx.gbl ¤¤¼¶¼g...
Hi Agnes,

Before I wrote this message I tested it completly again, while I have used
it before, however I could not simulate your problem so show some code as
you have implemented it?

Cor

Nov 20 '05 #8
Hi Agnes,

Can you try this sample, it needs one textbox and one button on a form.

I hope this helps?

Cor

\\\
Dim dt As New DataTable
Private Sub Form4_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
dt.Columns.Add( New DataColumn("myd ate", GetType(System. DateTime)))
dt.Rows.Add(dt. NewRow)
Dim Mybinding As New Binding("Text", dt, "mydate")
TextBox1.DataBi ndings.Add(Mybi nding)
AddHandler Mybinding.Forma t, AddressOf DBdateTextbox
AddHandler Mybinding.Parse , AddressOf TextBoxDBdate
dt.Rows(0)("myd ate") = New Date(2004, 7, 15)
End Sub
Private Sub DBdateTextbox(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Va lue)
cevent.Value = datum.ToString( "dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value.To String = "" Then
cevent.Value = DBNull.Value
End If
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
BindingContext( dt).EndCurrentE dit()
MessageBox.Show (dt.Rows(0)(0). ToString)
End Sub
///
Nov 20 '05 #9
Dear Cor,
I just try it.. [I overwrite the date to 16-07-2004 ,after press button
, it changed back >_< ]
Anyway, thanks for your kind help and coding.
I will try my best to search thr internet and seek the solution.
Thanks in advance
From Agnes

"Cor Ligthert" <no**********@p lanet.nl> ¦b¶l¥ó
news:%2******** ********@tk2msf tngp13.phx.gbl ¤¤¼¶¼g...
Hi Agnes,

Can you try this sample, it needs one textbox and one button on a form.

I hope this helps?

Cor

\\\
Dim dt As New DataTable
Private Sub Form4_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
dt.Columns.Add( New DataColumn("myd ate", GetType(System. DateTime)))
dt.Rows.Add(dt. NewRow)
Dim Mybinding As New Binding("Text", dt, "mydate")
TextBox1.DataBi ndings.Add(Mybi nding)
AddHandler Mybinding.Forma t, AddressOf DBdateTextbox
AddHandler Mybinding.Parse , AddressOf TextBoxDBdate
dt.Rows(0)("myd ate") = New Date(2004, 7, 15)
End Sub
Private Sub DBdateTextbox(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Va lue)
cevent.Value = datum.ToString( "dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(B yVal sender As Object, _
ByVal cevent As ConvertEventArg s)
If cevent.Value.To String = "" Then
cevent.Value = DBNull.Value
End If
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
BindingContext( dt).EndCurrentE dit()
MessageBox.Show (dt.Rows(0)(0). ToString)
End Sub
///

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1809
by: Carl | last post by:
Hi, to be use with SQL server database 1- From window form textbox object From this assignement, txtTOTAL.Text="0.00m"; How do you convert back to decimal type ? How do you assign a default datetime value to it ? How do you convert back the text enter by user into datetime ?
3
2468
by: Iwan Petrow | last post by:
Hi, I have a column of type datetime in a SQL Server database. I set and get this column with Web Services using dataset and send them to a Web App TextBox control. The collation of the database is SQL_Latin1_General_CP1_CI_AS (if it necessary I could change it). I didn't change options in Web service and Web app (web_config). The date is...
1
1579
by: Lerp | last post by:
Hi all, What do I have to do in order to get my value from my textbox that is formatted like 'mm/dd/yyyy' into a datetime database field ? Currently getting an error: Syntax error converting datetime from character string I have 2 validators on this form field as seen below along with a sub that is supposed to be called on...
1
2484
by: adolf garlic | last post by:
I'm having a problem with dates. (No not the sort that you have at christmas) I have a webform with a text box and a calendar control. You can either - enter a date manually (we are talking uk style here dd/mm/yyyy) in the textbox - click a date on the calendar which puts the date value in the textbox (uk style)
2
2286
by: Boonaap | last post by:
Hi all, In a user control, the user can put the cultureinfo to his preference, choosing between "nl-BE","fr-BE", and "en-US". this way all calendar and datetime properties are set in the right structure. In a webform I have two textboxes which are filled in by a CalendarPicker in a Pop-up window, a StartDate and an EndDate. Works fine.
9
1726
by: Simon Harvey | last post by:
Hi all, I'm having a bit of a problem working with dates. My computer is british, but I'm developing an american application so I therefore need to use american dates. But I can't get my DateTime object to "act" american. Let me give an example: In order to take in an american date, I tell it which culture the date will be formatted...
11
2167
by: Axel Dahmen | last post by:
Hi, I'm working in a team developing an international website. When I set the page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't seem to be able to parse a TextBox's date value (Exception message see below) correctly. The TextBox's value is coming from the DateTime.Now.ToShortDateString() function, so it's an...
5
5131
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. Could someone help me with the customization? Thanks. String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s,...
3
8813
by: David | last post by:
I am using .Net 2.0 and VS2005 with SQL server db. The datetime columns on SQL have the date and time in them. How can I display just the short date format (e.g. a datetime of 10/19/2006 11:23:57 AM to show as just 10/19/2006)? I do not want to use the SQL CONVERT on the query because it affects the sorting of the column in a GridView. If...
9
451
by: Hrvoje Voda | last post by:
How to convert text from textbox "12.05.1977" into "12/05/1977"? and also check if the text is in right format before converting? Hrcko
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.