文本框中的日期时间格式 [英] Datetime format in textbox

查看:93
本文介绍了文本框中的日期时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有人之前会发布解决方案,但我并没有记住。

所以我很抱歉再次提出同样的问题

我有绑定数据时间到文本框名称txtInvoice


我希望它显示在dd-mm-yyyy

我尝试txtInvoice.txt =格式(txtInvoice.txt,& ; dd-mm-yyyy),它的返回

错误。

任何人都知道这样做吗?

谢谢

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(txtInvoice.txt,"dd-mm-yyyy"), its return
error.
Anyone know to do it ??
Thanks

推荐答案

*" Agnes" < AG *** @ dynamictech.com.hk> scripsit:
* "Agnes" <ag***@dynamictech.com.hk> scripsit:
我把数据时间绑定到文本框名称txtInvoice

我希望它显示在dd-mm-yyyy
我试试txtInvoice.txt =格式( txtInvoice.txt,dd-mm-yyyy),其返回
错误。
I had bind a datatime to the textbox name txtInvoice

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




\\\

Dim d As Date = Date.Parse(txtInvoice.Text)

txtInvoice.Text = d.ToString(...)

///


-

Herfried K. Wagner [MVP]

< URL:http://dotnet.mvps.org/>



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

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


嗨Agnes,


它仍然在我的剪贴板上作为对John的回答,


我希望这有帮助吗?


Cor


Private Sub myroutine()

Mybinding = New Binding( " Text",ds.Tables(0)," mydatfield")

textdatfield.DataBindings.Add(Mybinding)

AddHandler mybinding.Format,AddressOf DBdateTextbox

AddHandler mybinding.Parse,AddressOf TextBoxDBdate

结束sub

Private Sub DBdateTextbox(ByVal sender As Object,_

ByVal cevent As ConvertEventArgs)

如果cevent.Value是DBNull。价值然后

cevent.Value =""

Else

Dim datum As Date

datum = CDate (cevent.Value)

cevent.Value = datum.ToString(" dd-MM-yyyy")

结束如果

End Sub

Private Sub TextBoxDBdate(ByVal sender As Object,_

ByVal cevent As ConvertEventArgs)

if cevent.Value.ToString =""然后

cevent.Value = DBNull.Value

结束如果

结束子

///
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.DataBindings.Add(Mybinding)
AddHandler mybinding.Format, AddressOf DBdateTextbox
AddHandler mybinding.Parse, AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString("dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///


亲爱的Cor,

它的工作原理但我要覆盖日期,它不允许。我过了

日期,例如15-07-2004到05-07-2004,在按''tab'后'

它改回''15 -07- 2004''

请~~~

来自AGnes

ps-你有一个cliboard?在哪里?


" Cor Ligthert" <无********** @ planet.nl> | b?l¥ó

新闻:OC ************** @TK2MSFTNGP12.phx.gbl¤¤??? g ...
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**********@planet.nl> |b?l¥ó
news:OC**************@TK2MSFTNGP12.phx.gbl ¤¤???g...
嗨艾格尼丝,

它仍然在我的剪贴板上作为约翰的答案,

我希望这有帮助吗?

Cor Mybinding = New Binding(" Text",ds.Tables(0)," mydatfield")
textdatfield.DataBindings.Add(Mybinding)
AddHandler mybinding.Format,AddressOf DBdateTextbox
AddHandler mybinding.Parse,AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(ByVal sender As Object,_
ByVal cevent As ConvertEventArgs)
如果cevent.Value是DBNull.Value则
cevent.Value =""
否则
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString(" dd-MM-yyyy")
结束如果
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object,_
ByVal cevent作为ConvertEventA rgs)
如果cevent.Value.ToString =""然后
cevent.Value = DBNull.Value
结束如果
// @
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.DataBindings.Add(Mybinding)
AddHandler mybinding.Format, AddressOf DBdateTextbox
AddHandler mybinding.Parse, AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString("dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///


这篇关于文本框中的日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆