我对编码和视觉基础很陌生。今天我被分配去完成一个我遇到问题的程序。我需要开发一个应用程序,允许用户输入约会和需要完成的时间,但是我需要实施错误检查以确保没有两次相同,这就是我遇到问题的地方. 我不确定如何将 adatetimepicker.value
与listbox
文本进行比较。我收到从string
“”到类型的转换Date
无效错误。任何帮助深表感谢!
Public Class Form1
Function TimeTaken() As Boolean
Dim app As String = TextBox1.Text
Dim timeofapp As String = DateTimePicker1.Value.ToShortTimeString
If CDate(ListBox2.Text) = CDate(DateTimePicker1.Value) Then
MsgBox("Two appointments are scheduled within the same time frame.", MsgBoxStyle.Exclamation)
TimeTaken = True
Else
TimeTaken = False
ListBox1.Items.Add(app)
ListBox2.Items.Add(timeofapp)
TextBox1.Text = ""
End If
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TimeTaken()
End Sub
End Class