Hi,
I am having a problem with the below,basically what I'm trying to do is allow the user to enter upper case,lower case ,or alternating text ..like Cw888 or cW888 for example using or ...
it works fine for one command button,that is it displays the error message if the user enters an invalid course and then clears the textbox and sets focus on that textbox allowing the user to re enter the correct course,but for some reason after it clears the textbox..and i reenter a valid course it just keeps diplaying an invalid course error....
Could I use a loop on the below? ,after an invalid course is entered the message box pops up..the textbox clears,and then the setfocus kicks in..but then it should go back to to the true statements if a valid course is enter?
Private Sub cmdprocess_averageresult_Click()
If txtvalidateaverage.Text = "cw888" Or txtvalidateaverage.Text = "CW888" Or txtvalidateaverage.Text = "cW888" Or txtvalidateaverage.Text = "Cw888" Then
'true values
lblaverageresultoncourse.Visible = True
lblprocesseddatadisplayed.Caption = Math.Round(intAveragecw888 / intCountcw888)
lblaverageresultoncourse.Caption = "Average Mark on course " & strCoursecw888
ElseIf txtvalidateaverage.Text = "cw019" Or txtvalidateaverage.Text = "CW019" Or txtvalidateaverage.Text = "Cw019" Or txtvalidateaverage.Text = "cW019" Then
'true values
lblaverageresultoncourse.Visible = True
lblprocesseddatadisplayed.Caption = Math.Round(intAveragecw019 / intCountcw019)
lblaverageresultoncourse.Caption = "Average Mark on course " & strCoursecw019
ElseIf txtvalidateaverage.Text = "cw046" Or txtvalidateaverage.Text = "CW046" Or txtvalidateaverage.Text = "Cw046" Or txtvalidateaverage.Text = "cW046" Then
'true values
lblaverageresultoncourse.Visible = True
lblprocesseddatadisplayed.Caption = Math.Round(intAveragecw046 / intCountcw046)
lblaverageresultoncourse.Caption = "Average Mark on course " & strCoursecw046
ElseIf txtvalidatenumber.Text <> "CW888" Or txtvalidatenumber.Text <> "CW019" Or txtvalidatenumber.Text <> "CW046" Then
'false value
MsgBox "Course Does not exist"
lblnumberofstudentsoncourse.Visible = False
lblprocesseddatadisplayed.Caption = " "
lblprocesseddatadisplayed.Visible = False
txtvalidatenumber.setfocus
txtvalidatenumber.Text = " "
End If
End Sub
Private Sub cmdprocess_numberofstudents_Click()
If txtvalidatenumber.Text = "cw888" Or txtvalidatenumber.Text = "CW888" Or txtvalidatenumber.Text = "cW888" Or txtvalidatenumber.Text = "Cw888" Then
lblnumberofstudentsoncourse.Visible = True
lblprocesseddatadisplayed.Caption = intcw888studentcount
lblnumberofstudentsoncourse.Caption = "Number of students on course " & strCoursecw888
ElseIf txtvalidatenumber.Text = "cw019" Or txtvalidatenumber.Text = "CW019" Or txtvalidatenumber.Text = "Cw019" Or txtvalidatenumber.Text = "cW019" Then
lblnumberofstudentsoncourse.Visible = True
lblnumberofstudentsoncourse.Caption = "Number of students on course " & strCoursecw019
lblprocesseddatadisplayed.Caption = intcw019studentcount
ElseIf txtvalidatenumber.Text = "cw046" Or txtvalidatenumber.Text = "CW046" Or txtvalidatenumber.Text = "Cw046" Or txtvalidatenumber.Text = "cW046" Then
lblnumberofstudentsoncourse.Visible = True
lblnumberofstudentsoncourse.Caption = "Number of students on course " & strCoursecw046
lblprocesseddatadisplayed.Caption = intcw046studentcount
ElseIf txtvalidatenumber.Text <> "CW888" Or txtvalidatenumber.Text <> "CW019" Or txtvalidatenumber.Text <> "CW046" Then
MsgBox "Course Does not exist"
lblnumberofstudentsoncourse.Visible = False
lblprocesseddatadisplayed.Caption = " "
lblprocesseddatadisplayed.Visible = False
txtvalidatenumber.setfocus
txtvalidatenumber.Text = " "
End If
End Sub
Private Sub cmdprocess_studentsoncourse_Click()
strcw888namegroup = lststudentname.List(0) & vbCrLf & lststudentname.List(2) & vbCrLf & lststudentname.List(3) & vbCrLf & lststudentname.List(7) & vbCrLf & lststudentname.List(8) & vbCrLf & lststudentname.List(11)
strcw046namegroup = lststudentname.List(9) & vbCrLf & lststudentname.List(12) & vbCrLf & lststudentname.List(17)
strcw019namegroup = lststudentname.List(1) & vbCrLf & lststudentname.List(4) & vbCrLf & lststudentname.List(5) & vbCrLf & lststudentname.List(6) & vbCrLf & lststudentname.List(10) & vbCrLf & lststudentname.List(13) & vbCrLf & lststudentname.List(15)
If txtvalidatenames.Text = "cw888" Or txtvalidatenames.Text = "CW888" Or txtvalidatenames.Text = "cW888" Or txtvalidatenames.Text = "Cw888" Then
lblprocesseddatadisplayed.Caption = strcw888namegroup
lblnamesoncoursetitle.Caption = "Names of students on course " & strCoursecw888
lblnamesoncoursetitle.Visible = True
ElseIf txtvalidatenames.Text = "cw019" Or txtvalidatenames.Text = "CW019" Or txtvalidatenames.Text = "Cw019" Or txtvalidatenames.Text = "cW019" Then
lblnamesoncoursetitle.Caption = "Names of students on course " & strCoursecw019
lblprocesseddatadisplayed.Caption = strcw019namegroup
lblnamesoncoursetitle.Visible = True
ElseIf txtvalidatenames.Text = "cw046" Or txtvalidatenames.Text = "CW046" Or txtvalidatenames.Text = "Cw046" Or txtvalidatenames.Text = "cW046" Then
lblnamesoncoursetitle.Caption = "Names of students on course " & strCoursecw046
lblprocesseddatadisplayed.Caption = strcw046namegroup
lblnamesoncoursetitle.Visible = True
ElseIf txtvalidatenames.Text <> "CW888" Or txtvalidatenames.Text <> "CW019" Or txtvalidatenames.Text <> "CW046" Then
MsgBox "Course Does not exist"
lblnamesoncoursetitle.Visible = False
lblprocesseddatadisplayed.Caption = " "
lblprocesseddatadisplayed.Visible = False
txtvalidatenames.SetFocus
txtvalidatenames.Text = ""
End If
End Sub