Tag: static

在Excel VBA中使用静态地图时出错

在GetCallOrPut = map(legOption)行放入我的error handling程序。 传入的值是=“C”。 当我一步一步地图时,地图正在初始化,我似乎无法弄清楚我错过了什么。 我有两个其他的function,使用类似的地图,并没有在那里的麻烦。 有什么想法吗? Public Function GetCallOrPut(ByVal legOption As String) As String 'Translates C to Call and P to Put in option Structure Static map As Collection If map Is Nothing Then Set map = New Collection map.Add "C", "Call" map.Add "P", "Put" End If GetCallOrPut = map(legOption) End Function

用作项目计数器的静态variables的生存期

我已经声明了一个静态variables来作为一个项目计数器使用。 电子表格将由运行代码的不同人员更新并随后保存工作簿。 但是,当我testing我的代码,并进行任何更改时,静态variables重置为1 : Static strn, mechn, ein As Integer Dim i, lrow As Long Dim num as String Set wb = ThisWorkbook Set ws = wb.Sheets("test") lrow = ws.Range("A" & Rows.Count).End(xlUp).Row i = 1 If reqb = "blah" Then Do Until ws.Range("B" & i).Value = "bloop" i = i + 1 Loop strn = […]