我试图解决dart中的Visual Basic分配问题,并且能够使用它:
我不知道这是否是最好的方法。在Visual Studio中,我不知道哪些命令或方法可以帮助我完成此操作,这就是结果。
Public Class Form1
Dim input As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "Nested Loops"
End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label.Click
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles InputTextBox.TextChanged
input = Val(InputTextBox.Text)
End Sub
Private Sub ComputeButton_Click(sender As Object, e As EventArgs) Handles ComputeButton.Click
For outer As Integer = 1 To input
For inner As Integer = 1 To outer
ListBox.Items.Add("#")
Next
ListBox.Items.Add("")
Next
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox.SelectedIndexChanged
End Sub
End Class
尝试像飞镖一样处理此错误
System.InvalidCastException:'从字符串“#”到类型“ Double”的转换无效。
我需要帮助。
考虑:
For outer As Integer = 1 To input
Dim s as String
For inner As Integer = 1 To outer
s &= "#"
Next
ListBox.Items.Add(s)
Next
也就是说,您想要一个每次增加一个#的字符串,然后再将其添加到将要显示它的东西中:
"#"
"##"
"###"
"####"
这使用简单的字符串连接。将来,当您为真实的程序进行编程时(例如,要运行一个创建数百万个字符串的过程),您应该考虑使用为该作业设计的工具,例如StringBuilder。不过,这对于少数几个操作来说是可以的
尽管我很困惑,为什么您使用列表框而不只是文本框。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句