vb 中怎么先给变量赋值,再在控件中使用
我在写这样一个过程:PrivateSubTimer7_Timer()DimuAsInteger,jAsInteger,kAsInteger,iAsIntegeru=u-1...
我在写这样一个过程:
Private Sub Timer7_Timer()
Dim u As Integer, j As Integer, k As Integer, i As Integer
u = u - 12: j = j - 12: k = k - 12: i = i - 12
End Sub
但uijk是有初始值的,在哪里赋值
timer中应该不行吧
或者是说把定义也放在前面..... 展开
Private Sub Timer7_Timer()
Dim u As Integer, j As Integer, k As Integer, i As Integer
u = u - 12: j = j - 12: k = k - 12: i = i - 12
End Sub
但uijk是有初始值的,在哪里赋值
timer中应该不行吧
或者是说把定义也放在前面..... 展开
展开全部
在代码窗口的最上面开始,进行声明变量
在窗体的 Load()事件里,进行初始赋值。
Dim u As Integer, j As Integer, k As Integer, i As Integer
Private Sub Timer7_Timer()
u = u - 12: j = j - 12: k = k - 12: i = i - 12
End Sub
Private Sub Form_Load()
u = 0
j = 1
k = 2
i = 3
End Sub
在窗体的 Load()事件里,进行初始赋值。
Dim u As Integer, j As Integer, k As Integer, i As Integer
Private Sub Timer7_Timer()
u = u - 12: j = j - 12: k = k - 12: i = i - 12
End Sub
Private Sub Form_Load()
u = 0
j = 1
k = 2
i = 3
End Sub
更多追问追答
追问
我前面已经有好多了过程了,可不可以在这个timer控件的上面进行赋值
追答
不可以
我已经给你样子了,
声明语句,放在所有代码的最上面!!!!!!
展开全部
Dim u As Integer, j As Integer, k As Integer, i As Integer
Private Sub Timer7_Timer()
u = u - 12: j = j - 12: k = k - 12: i = i - 12
End Sub
Private Sub Timer7_Timer()
u = u - 12: j = j - 12: k = k - 12: i = i - 12
End Sub
追问
在控件之前也可以赋值吗
追答
你这个是过程,不是控件。控件是摆在窗口里的
可以
如果在过程内定义变量,过程执行完毕后,所定义的变量失效,在过程外变量会保存,整个模块都可以用,如果用public来代替dim,那整个程序都可以使用这个变量
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询