主题:输入一个数 然后输出正方形[用控制台程序] 用*显示的比如 输入2就显示
8088cpu
[专家分:0] 发布于 2005-10-01 00:24:00
VB.NET输入一个数 然后输出正方形[用控制台程序] 用*显示的比如 输入2就显示
**
**
输入3就是
***
***
***
输入4就是
****
****
****
****
有人能教教我吗?
回复列表 (共4个回复)
沙发
5653325 [专家分:40] 发布于 2005-10-08 14:36:00
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i, i1, i2 As Integer
Dim ss As String
i = CInt(InputBox("请输入一个整数", "Input", "2"))
i1 = i
For i1 = 1 To i
ss = ""
For i2 = 1 To i
ss = ss & "*"
Next
Console.WriteLine(ss)
Next
Console.ReadLine()
End Sub
板凳
wyj82 [专家分:10] 发布于 2005-10-23 10:33:00
我试了不对啊
3 楼
宝宝啊呜 [专家分:990] 发布于 2005-10-24 16:28:00
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j, m As Integer
Dim ss As String
m = CInt(InputBox("请输入一个整数", "Input", "2"))
For i = 1 To m
For j = 1 To m
ss &= "*"
Next
ss &= vbNewLine
Next
TextBox1.Text = ss ’这里TextBox1.Multiline = True
End Sub
4 楼
宝宝啊呜 [专家分:990] 发布于 2005-10-24 17:05:00
不好意思,米看到是用控制台程序,那就改成:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i, j, m As Integer
Dim ss As String
m = CInt(InputBox("请输入一个整数", "Input", "2"))
For i = 1 To m
For j = 1 To m
ss &= "*"
Next
ss &= vbNewLine
Next
Console.WriteLine(ss)
Console.ReadLine()
End Sub
我来回复