我有一个带有initialize事件的userform,如下所示:
Public CurrSpanNum, CurrSegNum As Integer
Private Sub UserForm_Initialize()
CurrSegNum = Sheets("UserData").Range("C2").value
Debug.Print "SegForm, SpanNum = " & CurrSpanNum
CurrSpanNum = Sheets("UserData").Range("D2").value
Debug.Print "SegForm, SegNum = " & CurrSegNum
End Sub
在即时窗口中,我看到:
SegForm, SpanNum =
SegForm, SegNum = 3
在初始化表单之前,将值3放在两个单元格中。为什么我不能在SegNum能够加载时加载SpanNum?
答案 0 :(得分:4)
好吧,你的CurrSpanNum变量没有被初始化,所以什么都不打印,你会期待什么?