vb.net - 'ElseIf' must be preceded by a matching 'If' or 'Elsif' -


hi coding blackjack game school project. have encountered error. when run program code says 'elseif' must preceded matching 'if' or "elsif'. have tried lots of different arrangements cannot figure out. below code msgbox.

please help

    dim responseyouwon = msgbox(youwonmsg, style, youwontitle)     dim responseyoulost = msgbox(youlostmsg, style, youlosttitle)     dim responseyoudrew = msgbox(youdrewmsg, style, youdrewtitle)      if playersum < 21 , playersum > computersum         if responseyouwon = msgboxresult.yes             btnplayagain.performclick()         else             btnquit.performclick()         end if     end if      elseif computersum > 21 , playersum < 21     if responseyouwon = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()     end if      elseif computersum > 21 , computersum < 21     if responseyouwon = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()     end if      elseif playersum = 21 , computersum > 21     if responseyouwon = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()     end if      elseif playersum = 21 , computersum < 21     if responseyouwon = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()     end if      elseif computersum < 21 , computersum > playersum     if responseyoulost = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()     end if      elseif playersum > 21 , computersum < 21     if responseyoulost = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()     end if      elseif computersum = 21 , playersum <> 21     if responseyoulost = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()     end if      elseif computersum = playersum     if responseyoudrew = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()         end if      elseif playersum > 21 , computersum > 21     if responseyoudrew = msgboxresult.yes         btnplayagain.performclick()     else         btnquit.performclick()     end if  end sub 

you can make way easier on yourself:

if playersum > 21 playersum = 0 if computersum > 21 computersum = 0  dim response msgboxresult if playersum > computersum     response = msgbox(youwonmsg, style, youwontitle) elseif computersum > playersum     response = msgbox(youlostmsg, style, youlosttitle) else     response = msgbox(youdrewmsg, style, youdrewtitle) end if  if response = msgboxresult.yes     btnplayagain.performclick() else     btnquit.performclick() end if 

but original code... @ end if closing statement on line 11.


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -