附加信息:从字符串“1:夜间F3,购买10张门票”到“整数”类型的转换无效。“
Dim filename As String
Dim fridaytickets As Integer
fridaytickets = 0
filename = "Z:\Computing Science\S5 (Higher)\Coursework Assessment\output.txt"
FileOpen(1, filename, OpenMode.Output)
For x = 1 To 300
If Mid(TicketID(x), 1, 1) = "F" Then
PrintLine((x) & ": Night " & TicketID(x) & ", " & TicketNo(x) & " tickets purchased. £" & (TicketNo(x) * 10) & " made.")
fridaytickets = fridaytickets + TicketNo(x)
End If
PrintLine(fridaytickets & " were purchased for Friday night.")
PrintLine("£" & (fridaytickets * 10) & " was made.")
答案 0 :(得分:0)
这是一行:
PrintLine(fridaytickets & " were purchased for Friday night.")
你的fridaytickets
是一个整数,奇怪的是,似乎&
被视为二元运算符,所以两边都是整数。它应该不是这样,但也许它是一个bug或版本依赖。或者只是正常连接运算符的重载。
在任何情况下,正确的方法是准备要连接的字符串:
PrintLine(fridaytickets.toString & " were purchased for Friday night.")