[英]What is wrong with this msgbox code? (VB)
编辑:别担心,我犯了一个愚蠢的错误,我有3个字符而不是4个字符
MessageBox.Show("Well done you completed the game in " & (Label4.Text.Substring(0, 2)) & ":" & (Label4.Text.Substring(2, 2)) & " milliseconds. Well Done!")
那为什么不起作用呢? 如果有帮助,这里是错误代码:
“ mscorlib.dll中发生了'System.ArgumentOutOfRangeException类型的未处理的异常
附加信息:索引和长度必须引用字符串中的位置。”
我怀疑您的Label4.Text
属性比您要求的短。
您能告诉我'Label4'到底包含什么,我知道它有数字,但还有其他文字。 很抱歉将其作为答案,但是“注释”按钮不在页面上的任何位置。
我知道您已经接受了答案,但是我正在答复您希望它在几秒钟内显示的评论。 尝试这样的事情:
Dim result As Integer
If Integer.TryParse(Label4.text, result) Then
MessageBox.Show("Well done you completed the game in " & (result / 1000).ToString & " seconds. Well Done!")
Else
MessageBox.Show("Well done you completed the game in null seconds. Well Done!")
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.