vb.net - Index outside bounds in event handler -


i'm having trouble displaying shipping price lblshipping.text

option explicit on option strict on option infer off  public class frmmain     private intmin() integer = {1, 11, 51, 101}     private intmax() integer = {10, 50, 100}     private dblship() double = {15, 10, 5, 0}      private sub btnexit_click(byval sender object, byval e system.eventargs) handles btnexit.click         me.close()     end sub      private sub txtordered_keypress(byval sender object, byval e system.windows.forms.keypresseventargs) handles txtordered.keypress         ' allows text box accept numbers , backspace key          if (e.keychar < "0" orelse e.keychar > "9") andalso e.keychar <> controlchars.back             e.handled = true         end if     end sub      private sub txtordered_textchanged(byval sender object, byval e system.eventargs) handles txtordered.textchanged         lblshipping.text = string.empty     end sub      private sub btndisplay_click(byval sender system.object, byval e system.eventargs) handles btndisplay.click          dim intordered integer         integer.tryparse(txtordered.text, intordered)          intindex integer = 0 3             if intordered <= 2                 if intordered >= intmin(intindex) , intordered <= intmax(intindex)                     lblshipping.text = dblship(intindex).tostring("c2")                 end if             end if             if intindex = 3                 if intordered >= intmin(intindex)                     lblshipping.text = dblship(intindex).tostring("c2")                 end if             end if         next intindex     end sub end class 

try delete statements

private sub txtordered_textchanged(byval sender object, byval e system.eventargs) handles txtordered.textchanged     lblshipping.text = string.empty end sub 

and try change next statements

for intindex integer = 0 3         if intordered <= 2             if intordered >= intmin(intindex) , intordered <= intmax(intindex)                 lblshipping.text = dblship(intindex).tostring("c2")             end if        elseif intindex = 3             if intordered >= intmin(intindex)                 lblshipping.text = dblship(intindex).tostring("c2")             end if         end if     next intindex 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -