标题:
[基础]
用VB畫出方格??
[打印本页]
作者:
napa6101
时间:
2009-2-5 21:08
标题:
用VB畫出方格??
習題,不知道錯什麼= = ..................
問題是, 例如 輸入5 出現
*****
* *
* *
* *
*****
輸入2 出現
**
**
如此類推
以下是我自已寫的~
Dim x As Integer
x = InputBox("Enter value for number (1~10)", "Input x")
Dim i As Integer = 0
Dim j As Integer = 1
While i < x
j = 1
While j <= x
Print("*")
j += j
End While
Print(vbCrLf)
i += i
End While
[
本帖最后由 napa6101 于 2009-2-5 22:36 编辑
]
作者:
Nothing
时间:
2009-2-6 19:07
下面是VB6的代码
Dim
x As Integer
,
i As Integer
x
=
InputBox
(
"Enter value for number (1~10)"
,
"Input x"
)
For
i
=
1
To
x
Print
String
(
x
,
"*"
)
Next
作者:
Nothing
时间:
2009-2-6 19:11
VB.Net的
Dim x As Integer, i As Integer
x = InputBox("Enter value for number (1~10)", "Input x")
For i = 1 To x
Print StrDup(x, "*")
Next
作者:
napa6101
时间:
2009-2-7 19:30
寫到了~
Dim x, i, j As Integer
x = InputBox("Enter value for number (1~10)", "Input x")
laloutput.Text = ""
For i = 1 To x
For j = 1 To x
If (i = 1 Or i = x) Or (j = 1 Or j = x) Then
laloutput.Text += "*"
Else
laloutput.Text += " "
End If
Next j
laloutput.Text += vbCrLf
Next i
End Sub
欢迎光临 编程开发论坛 (http://bbs.lihuasoft.net/)
Powered by Discuz! 6.0.0