Visual Basic WinForm 用循环实现直角三角形的类型转换错误解决
我曾尝试使用Dart完成这项Visual Basic作业,且已通过下述方案实现了效果:

不过我不确定该实现是否为最优方案,也不清楚Visual Studio中有哪些可用的命令或方法可帮助我完成该需求,目前我编写的VB代码如下:
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

我尝试参照Dart的逻辑处理该问题时,出现了如下报错:
System.InvalidCastException: 'Conversion from string "#" to type 'Double' is not valid.'
现寻求该问题的解决方法。
内容的提问来源于stack exchange,提问作者Nana Kwame
相关产品推荐
相关产品推荐

