以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何循环定义变量,并让其作用域为for循环外 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=177927) |
-- 作者:guosheng -- 发布时间:2022/6/10 12:58:00 -- 如何循环定义变量,并让其作用域为for循环外 1、想定义 time1 tme2 …………time10,以下报错了,该怎么用啊? For i As Integer= 1 To 10 Dim time & i As String Next 2、以上定义只能在for循环内部才能获取time1或time2,如何在for循环外也能引用相应的值啊。
|
-- 作者:有点蓝 -- 发布时间:2022/6/10 13:41:00 -- 变量名称必须是确定的,无法定义动态变量。在for循环外也能引用必须在循环外部定义。 这种情况建议使用字典 dim dict as new dictionary(of string,string) For i As Integer= 1 To 10 dict.add("time" & i,"某某值" & i) Next msgbox(dict("time2"))
|