看看我的VB代码哪错了

来源:百度知道 编辑:UC知道 时间:2024/06/03 04:31:07
Private Sub ReloadAll()
Dim i As Integer
For i = 0 To Total - 1
Sdut(i).OutPut.Top = (i - 1) * RowHeight + RowTopBegin
Sdut(i).Check.Top = (i - 1) * RowHeight + RowTopBegin
Next i
End Sub

其中sdut()是个数组
output和check都是动态生成的控件
RowTopBegin,RowHeight 都是常数
现在要调整位置
上面的语句编译通过不了
说是with模块变量未设置
帮帮我吧
Private Type record
OutPut As TextBox '信息输入框
Check As CheckBox '选定框
ID As String
End Type

Dim Sdut() As record

是这样定义的

你在load生成动态控件后要建立sdut对控件的引用
例如set sdut(0).output = text1(0)
这样就可以了。

很可能你没有这么做

比如窗体上有一个text1

dim a as textbox

set a = text1
a.text = "a"
这样才能更改text1的内容,仅仅
dim a as textbox

a.text = "a"
就会出现with模块变量未设置的问题

sdut()是不是保存控件的数组啊?如果是的话,应该是用
sdut(i).top=...来访问数组成员的属性

那就看不出来了,除了Total以外别的都没有什么问题了,你运行的时候看看出错的停在哪个上面就知道哪个没定义了。