vb.net - How to show all validation errors as a list in my messagebox -


i having problem code. trying show validation errors in message box. can tell me why 1 of errors showing in box? tried couple more solutions , looked around need little please.

public class form1 private sub btncalculate_click(sender object, e eventargs) handles btncalculate.click     if data_validated_ok() = false exit sub   end sub private function data_validated_ok() boolean      dim interrcount integer     dim strerrmessage string = string.empty     dim ctrlerror new collection      ' make sure premium channel selected      if me.lstpremium.selectedindex < 0         interrcount = interrcount + 1         strerrmessage = interrcount & ". premium channels required field." _         & vbcrlf         ctrlerror.add(lstpremium.selectedindex)     end if     ' make sure customer type selected in radioboxes      if radbusiness.checked = false ,                 radresidential.checked = false         interrcount = interrcount + 1         strerrmessage = interrcount & ".customer type required field." _          & vbcrlf         ctrlerror.add(radbusiness.checked, radresidential.checked)     end if      ' make sure business customer checks @ least 1 option in listbox      if radbusiness.checked = true , me.lstconnections.selectedindex < 0         interrcount = interrcount + 1         strerrmessage = interrcount & ". business customers must select 1 or more connection." _         & vbcrlf         ctrlerror.add(lstconnections.selectedindex)     end if      ' show errors in messagebox      if interrcount > 0         messagebox.show(strerrmessage, "validation rule(s)", messageboxbuttons.ok, messageboxicon.information)         dim ctrl control         ctrl = ctrlerror.item(1)         ctrl.focus()         return false     else         return true     end if  end function 

how storing each error in list(of string)? variable ctrlerror not storing controls, integers , booleans - should have casting errors there.

private function data_validated_ok() boolean   dim errormsgs new list(of string) ' make sure premium channel selected    if me.lstpremium.selectedindex < 0      errormsgs.add("premium channels required field.")   end if ' make sure customer type selected in radioboxes    if radbusiness.checked = false andalso             radresidential.checked = false     errormsgs.add("customer type required field.")   end if  ' make sure business customer checks @ least 1 option in listbox    if radbusiness.checked = true , me.lstconnections.selectedindex < 0     errormsgs.add("business customers must select 1 or more connection.")   end if  ' show errors in messagebox    if errormsgs.count > 0     messagebox.show(string.join(environment.newline, errormsgs.toarray), "validation rule(s)", messageboxbuttons.ok, messageboxicon.information)     return false   else     return true   end if  end function 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -