嗨,我试图在我的程序中设计一个部分来构建由矩形表示的层,这取决于输入的大小将决定矩形宽度的结果。我在输入 < 0 时遇到问题,它将恢复为 1 或 0。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rectangle As Integer
rectangle = Val(TextBox1.Text)
TextBox1.Text = Convert.ToString(rectangle)
Form2.RectangleShape1.Width = Val(TextBox1.Text)
If Val(TextBox1.Text) >= 1.0 Or Val(TextBox1.Text) <= 1.5 Then
Form2.RectangleShape1.Width = 75
End If
If Val(TextBox1.Text) >= 1.5 Then
Form2.RectangleShape1.Width = 120
End If
If Val(TextBox1.Text) <= 1.0 Then
Form2.RectangleShape1.Width = 55
End If
Form2.RectangleShape1.Show()
Me.Hide()