现在进行第一次判断并增加赢输和平的次数
If goalsFor > goalsAgainst Then
wins +=
ElseIf goalsFor < goalsAgainst Then
losses +=
Else
draws +=
End If
End While
一旦循环结束总数将被显示在标签中
LabelText = winsToString()
LabelText = lossesToString()
LabelText = drawsToString()
LabelText = goalsForToString()
LabelText = goalsAgainstToString()
接下来要计算胜负比率(不管球队的表现如何您都可以假定该值为o!)然而在计算之前您需要确保失败次数不为否则会发生除数为的异常因此如果失败次数为则显示一条消息而且Return命令强制退出Page _Load事件处理程序
If losses = Then
LabelText = No losses a perfect season
Return
End If
如果该队至少失败一场则计算胜负比率
winRatio = ConvertToInt((wins / losses) * )
现在可以根据获胜率显示不同的消息记得要按照Case语句声明的顺序使用因此Case Else表示高于%的获胜率
Select Case winRatio
Case
LabelText = No wins Relegation is a certainty
Case Is <
LabelText = Less than % Very poor
Case Is <
LabelText = Under half Could do better
Case Is <
LabelText = Winning more than losing Excellent
Case Else
LabelText = A high ratio near the top of the table
End Select
所有这些语句(循环和判断)本身都非常简单但是这些语句结合在一起就显示了该代码的强大功能使用越来越多的语句可以增强代码功能但同时也增加了应用程序的复杂性
下一节将介绍命名空间其中的代码可以按照基本方法进行排列
ASPNET 入门教程完整版
[] [] [] [] [] [] [] []