VB 在textbox中输出数组
我有个数组有1000个元素,在窗体上用print方法输出使窗体变得很大,我想把这1000个元素输出在textbox中,只要在textbox中加上滚动条就行了,但现在我的问...
我有个数组有1000个元素,在窗体上用print方法输出使窗体变得很大,我想把这1000个元素输出在textbox中,只要在textbox中加上滚动条就行了,但现在我的问题是怎样在textbox中用for循环输出数组呢?
展开
推荐于2016-11-29
展开全部
Private Sub Command1_Click()
ReDim a(1 To 1000) As Integer
Dim i As Integer
Dim l As Integer
Dim s As String
Dim s1 As String
For i = 1 To 1000
a(i) = i
Next i
l = 12
For i = 1 To 1000
s1 = "a(" & CStr(i) & ")=" & CStr(a(i))
s1 = s1 & Space$(l - Len(s1))
s = s & s1
If i Mod 10 = 0 Then s = s & vbCrLf: s1 = ""
Next i
Text1.Text = s
End Sub
ReDim a(1 To 1000) As Integer
Dim i As Integer
Dim l As Integer
Dim s As String
Dim s1 As String
For i = 1 To 1000
a(i) = i
Next i
l = 12
For i = 1 To 1000
s1 = "a(" & CStr(i) & ")=" & CStr(a(i))
s1 = s1 & Space$(l - Len(s1))
s = s & s1
If i Mod 10 = 0 Then s = s & vbCrLf: s1 = ""
Next i
Text1.Text = s
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
Dim a(1 To 1000) As Integer
'在text的属性栏设置这2个属性
'text1.ScrollBars = 2 - vertical
'Text1.MultiLine = True
Text1.Text = ""
For i = 1 To 1000
a(i) = i
Text1.Text = Text1.Text & a(i) & " "
Next i
End Sub
Dim a(1 To 1000) As Integer
'在text的属性栏设置这2个属性
'text1.ScrollBars = 2 - vertical
'Text1.MultiLine = True
Text1.Text = ""
For i = 1 To 1000
a(i) = i
Text1.Text = Text1.Text & a(i) & " "
Next i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
for i = 1 to 1000
s = s & a(i) & vbcrlf
next
text1.text = s
s = s & a(i) & vbcrlf
next
text1.text = s
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询