G
Gary Simpson
Guest
Hi Good People
I am Trying to write code for one textbox, The textbox, I want to use for holding two date/Years Like (2019-2020) with a hyphen separating the two Years, How or can some good people tell me or show me how I can achieve this. I have tried using Text Length. I have tried using Count to no Avail. The code I have at the moment is Below.
Private Sub cmdSaveYears_Click(sender As Object, e As EventArgs) Handles cmdSaveYears.Click
Dim Temp1 = lbYears.Text
If txtYears.Text = "" Then
MsgBox("Please insert two consecutive Years " & vbCrLf & vbCrLf & _
" IE 2019-2020 or 2020-2021", MsgBoxStyle.OkCancel, "Dates Missing")
If MsgBoxResult.Cancel Then
txtYears.Text = Temp1.ToString
cmdSaveYears.Enabled = True
Else
lbYears.Text = txtYears.Text
lbYears1.Text = txtYears.Text
txtYears.Enabled = False
End If
End If
End Sub
As you can see I have only the code if no dates are inserted into textbox (txtYears) and if no text is put in the textbox (txtYears) Then I Put the Years back in the textbox that was in the textbox before changing the Years using Temp1 in my code Please can you point me in the right direction. Also how can I check if the two years are consecutive and the User has put the correct format in the textbox.
Regards Gary.
Gary Simpson
Continue reading...
I am Trying to write code for one textbox, The textbox, I want to use for holding two date/Years Like (2019-2020) with a hyphen separating the two Years, How or can some good people tell me or show me how I can achieve this. I have tried using Text Length. I have tried using Count to no Avail. The code I have at the moment is Below.
Private Sub cmdSaveYears_Click(sender As Object, e As EventArgs) Handles cmdSaveYears.Click
Dim Temp1 = lbYears.Text
If txtYears.Text = "" Then
MsgBox("Please insert two consecutive Years " & vbCrLf & vbCrLf & _
" IE 2019-2020 or 2020-2021", MsgBoxStyle.OkCancel, "Dates Missing")
If MsgBoxResult.Cancel Then
txtYears.Text = Temp1.ToString
cmdSaveYears.Enabled = True
Else
lbYears.Text = txtYears.Text
lbYears1.Text = txtYears.Text
txtYears.Enabled = False
End If
End If
End Sub
As you can see I have only the code if no dates are inserted into textbox (txtYears) and if no text is put in the textbox (txtYears) Then I Put the Years back in the textbox that was in the textbox before changing the Years using Temp1 in my code Please can you point me in the right direction. Also how can I check if the two years are consecutive and the User has put the correct format in the textbox.
Regards Gary.
Gary Simpson
Continue reading...