数组赋植问题

leweizhen 2003-10-09 10:04:33
小第有两个关于以下程序有两个问题,在窗体上画了3个命令按钮。

1。我用initial array初始化数组,再用out array打印出数组时为什么不10个一行的显示,而是一个一行?

2。等我在用initial array(2)再次初始化数组后,再用out array打印数组时,为什么打印出来的不变(我在initial array(2)中又重新初始化了数组)?

望各位大虾告之,谢谢了!

Dim counter As Integer
Dim workarea(2500) As String


Private Sub Command1_Click()


For counter = 0 To 2500
workarea(counter) = "initial value" & counter

Next counter

End Sub

Private Sub Command2_Click()


For counter = LBound(workarea) To UBound(workarea)
If counter Mod 100 = 0 Then Print
Print workarea(counter)

Next counter


End Sub

Private Sub Command3_Click()

For counter = 0 To 2500
workarea(counter) = "1111111initial value" & counter

Next counter


End Sub



Private Sub Form_Load()
Command1.Caption = "initial array"
Command2.Caption = "output array"
Command3.Caption = "initial array(2)"
End Sub
...全文
32 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
leweizhen 2003-10-09
  • 打赏
  • 举报
回复
真是太感谢了,你写的程序确实解决了问题,但我的程序问题在哪里呢??
leweizhen 2003-10-09
  • 打赏
  • 举报
回复
第二个问题是不是把form1窗口的autoredraw设为true?
还是不行啊.还是只能显示一个数组,再初始化另一个数组,打印出来的还是没变啊.
MSSQL 2003-10-09
  • 打赏
  • 举报
回复
以下程序可以解决你的问题
Dim counter As Integer
Dim workarea(2500) As String
Dim tempstr
Private Sub Command1_Click()
For counter = 0 To 2500
workarea(counter) = "initial value" & counter
Next counter
End Sub
Private Sub Command2_Click()
Me.Cls
For counter = LBound(workarea) To UBound(workarea)
If counter Mod 100 = 0 Then tempstr = tempstr & vbCrLf
tempstr = tempstr & workarea(counter)
Next counter
Print tempstr
End Sub
Private Sub Command3_Click()
For counter = 0 To 2500
workarea(counter) = "1111111initial value" & counter
Next counter
End Sub
Private Sub Form_Load()
Command1.Caption = "initial array"
Command2.Caption = "output array"
Command3.Caption = "initial array(2)"
End Sub
MSSQL 2003-10-09
  • 打赏
  • 举报
回复
第二个问题是你的窗口没有刷新了。
你要将窗口的autoredraw设为true

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧