vb代码没错,但运行不了,为什么?
麻烦走过瞧见的帮我看看,谢谢!
下面这段代码是抄的书上的,可是在我的电脑上出现了问题。运行时报错。
第四行和第六行报错。
Private Sub Command1_Click()
Dim i
i = DateDiff("d", CDate(Text1), CDate(Text2))
Label3.Caption= "日期差:"&i& "天"
i = Abs(i)
Label4.Caption="绝对值之差:"&i&"天"
End Sub
Private Sub Form_Load()
test2.Text = Date
End Sub
vb command date 运行不了
[解决办法]
到底是Text2还是Test2
[解决办法]
Private Sub Command1_Click()
Dim i
i = DateDiff("d", CDate(Text1), CDate(Text2))
Label3.Caption= "日期差:" & i & "天"
i = Abs(i)
Label4.Caption= "绝对值之差:" & i & "天"
End Sub
Private Sub Form_Load()
Text2.Text = Date
End Sub
Private Sub Command1_Click()
Dim i
i = DateDiff("d", CDate(Text1.text), CDate(Text2.text))
Label3.Caption= "日期差:"& i & "天"
Label3.refresh
i = Abs(i)
Label4.Caption="绝对值之差:"& i &"天"
Label4.refresh
End Sub
Private Sub Form_Load()
test2.Text = format(now(),"YYYY-MM-DD")
End Sub
Private Sub Command1_Click()
Dim i
i = DateDiff("d", _
CDate(Format(Text1.Text, "yyyy-mm-dd HH:mm:ss")), _
CDate(Format(Text3.Text, "yyyy-mm-dd HH:mm:ss")))
Label3.Caption = "日期差:" & i & "天"
i = Abs(i)
Label4.Caption = "绝对值之差:" & i & "天"
End Sub
Private Sub Form_Load()
'test2.Text = Format(Now, "yyyy-mm-dd")
Text2.Text = Format(Now, "yyyy-mm-dd")
Text1.Text = Format(Now, "yyyy-mm-dd")
Text3.Text = "2011-1-1"
End Sub