【发布时间】:2016-09-03 09:04:51
【问题描述】:
我是用 asp 和 vb 编写的新手,我被困在一个逻辑上,我需要从 web 表单中检索数据,计算条目数,然后按字母数字顺序排列。
我有一个带有多个可以填写和提交的文本框的网络表单,看起来有点像这样:(请原谅电子表格,它只是一个视觉辅助)
我已经创建了一个包含它们的值的数组,如下所示:
myArray = array(town, medal, record, sport)
我想统计和排序(按字母数字顺序)总奖牌、每个城镇赢得的奖牌数量以及每个城镇创造的记录数量。
我的伪代码看起来有点像这样,希望我在逻辑方面有点走上正轨。我不太了解的主要领域是知道哪些语句是好的以及在哪里,尤其是按字母数字顺序排列它们。
'this is the psuedocode for the total medals per town
tally = 0 'Set tally to 0
for myArray(town) 'For each town
for myArray(medal) 'For each medal
tally = tally + 1 'Add 1 to the total tally
response.write(myArray(town) "has" tally "medals" & "<br>")
next
next
'this is the pseudocode for the individual medals
for myArray(town) 'For each town
for myArray(medal) 'For each medal
goldTally = 0
silverTally = 0
bronzeTally = 0
if medal = "G"
goldTally = goldTally + 1
elseif medal = "S"
silverTally = silverTally + 1
else medal = "B"
bronzeTally = bronzeTally + 1
response.write(myArray(town) "has:" goldTally "gold medals" &"<br>"
silverTally "silver medals" &"<br>"
bronzeTally "bronze medals" &"<br>"
next
next
如果您能提供任何帮助,我们将不胜感激。
【问题讨论】: