Re: [請益] visual basic日期的問題
我不知道VB.net有沒有 try-catch 的東西.
但傳統上,VB有 On Error Goto 的事情.
※ 引述《cherryapril (偲)》之銘言:
: 我是才剛學visual basic的新手
: 想要寫一個可以計算從出生到現在過了幾天的程式。
: 希望能夠讓使用者方便,可以輸入各種數字或文字,
: 但只要並非日期就會跳出錯誤的警告框。
: 但現在卡在只要一輸入文字或數字程式就會整個crash
: 嘗試用if then來寫但沒用Q_Q
: 用if not 也一直出現date和if not不相容Q__________Q
: 跪求強者幫忙Q____________Q
: Option Strict On
: Public Class Form1
: Private Sub btncompute_Click(ByVal sender As System.Object, ByVal e As
: System.EventArgs) Handles btncompute.Click
On Error Goto Out_btncompute_Click
: Dim d As Date = CDate(TextBox1.Text)
: txttoday.Text = FormatDateTime(Today)
: txtfromnowon.Text = FormatNumber(DateDiff(DateInterval.Day, d,
: Today), 0)
Exit Sub
Out_btncompute_Click:
DoEvents
: End Sub
: End Class
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.167.54.26
→
09/26 12:45, , 1F
09/26 12:45, 1F
→
09/26 12:46, , 2F
09/26 12:46, 2F
推
09/27 13:17, , 3F
09/27 13:17, 3F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章