晚期约束问题 [英] Late Binding Question
问题描述
我正在转换写入Excel电子表格的应用程序,并且
代码会跳过选项严格选项。我希望因为解析器说
选项Strict On禁止后期绑定,我很难理解为什么
我正在绊倒这个错误。
这是导致问题的代码:
XLApp.Goto(" MonthTitleTL")''转到工作表中的书签
r = XLApp.ActiveCell.Row''将变量r等于
到该单元格的行
c = XLApp.ActiveCell.Column''设置c变量
该单元格的列
对于n = 0到11''处理在T7Lines中保存的12个月的
数据(n )集合
XLApp.Cells(r,c).Formula = T7Lines(n).TextMonthNumber
XLApp.Cells(r + 3,c).formula =
格式(T7Lines(n).RiskPointsTotal," 0.0")
....
下一页
我没有得到a)为什么这被归类为后期绑定?和b)我做什么停止
除了关闭严格的选项,我不想做。
任何帮助表示感谢。
Siv
Martley,英国伍斯特附近。
< BLOCKQUOTE>"西夫" < g@removethistextsivill.comschrieb
我没有得到a)为什么这被归类为后期绑定?
如果没有看到变量声明,就不可能看出它是否是后期执行的
。
和b)我做什么
除了关闭选项严格我不想
。
1.项目 - 添加参考-COM选项卡 - 添加Microsoft Excel xy
对象库
2.声明变量,例如,As Excel.Application
然后,您将被绑定到目标
计算机上的引用Excel版本。
Armin
Armin,
Vars如下:
在代码取自的程序中:
Dim n as integer = 0
Dim r as integer = 0
XLApp var在类的顶部声明如下:
私有XLApp作为XL.Application
调用我在这里复制的程序的处理块的开始,
我测试XLApp是否已经打开并且如果没有打开它:
如果IsNothing(XLApp) )然后
XLApp =新XL.Application
结束如果
我希望这就是你所需要的。
Siv
" Armin Zingler" < az ******* @ freenet.dewrote in message
news:uQ ************** @ TK2MSFTNGP05.phx.gbl ...
" Siv" < g@removethistextsivill.comschrieb
>我没有得到a)为什么这被归类为后期绑定?
如果没有看到变量声明,就不可能看出它是否是后期执行的
。
>和b)我做什么
停止它除了关闭严格的选项我不想做什么呢? 。
1.项目 - 添加参考-COM选项卡 - 添加Microsoft Excel xy对象
库
2.声明变量,例如,As Excel.Application
然后,您将被绑定到目标
计算机上的引用Excel版本。
Armin
Armin,
Vars如下:
在执行代码的过程中:
Dim n as integer = 0
Dim r as integer = 0
XLApp var在类的顶部声明如下:
Private XLApp As XL.Application
在处理块的开头调用我在这里复制的程序,
我测试XLApp是否已经打开并且如果没有打开它:
如果IsNothing(XLApp)那么
XLApp =新的XL.Application
结束如果
我希望这是你需要的。
S. iv
Armin Zingler < az ******* @ freenet.dewrote in message
news:uQ ************** @ TK2MSFTNGP05.phx.gbl ...
" Siv" < g@removethistextsivill.comschrieb
>我没有得到a)为什么这被归类为后期绑定?
如果没有看到变量声明,就不可能看出它是否是后期执行的
。
>和b)我做什么
停止它除了关闭严格的选项我不想做什么呢? 。
1.项目 - 添加参考-COM选项卡 - 添加Microsoft Excel xy对象
库
2.声明变量,例如,As Excel.Application
然后,您将被绑定到目标
计算机上的引用Excel版本。
Armin
hi,
I am converting an application that writes to an Excel spreadsheet and the
code trips the "option Strict" that I would like on because the parser says
"option Strict On disallows late binding", I am struggling to understand why
I am tripping this error.
This is the code that causes the problems:
XLApp.Goto("MonthTitleTL") ''Goes to bookmark in sheet
r = XLApp.ActiveCell.Row ''sets variable r equal
to the row of that cell
c = XLApp.ActiveCell.Column ''Sets the c variable to
the column of that cell
For n = 0 To 11 ''Process the 12 months of
data held in the T7Lines(n) collection
XLApp.Cells(r, c).Formula = T7Lines(n).TextMonthNumber
XLApp.Cells(r + 3, c).formula =
Format(T7Lines(n).RiskPointsTotal, "0.0")
....
Next n
I don''t get a) why this is classed as late binding? and b) what I do to stop
it other than turn off option strict which I don''t want to do.
Any help appreciated.
Siv
Martley, Near Worcester, UK.
"Siv" <g@removethistextsivill.comschriebI don''t get a) why this is classed as late binding?Without seeing a variable declaration, it''s impossible to see if it''s
late bound execution.
and b) what I do
to stop it other than turn off option strict which I don''t want to
do.1. Project -Add reference -COM tab -Add "Microsoft Excel x.y
Object Library"
2. Declare variables, for example, "As Excel.Application"
Then you are bound to the referenced Excel version on the target
machine.
Armin
Armin,
Vars as follows:
In the procedure that the code was taken from:
Dim n as integer = 0
Dim r as integer = 0
The XLApp var is declared at the top of the class as follows:
Private XLApp As XL.Application
At the start of the processing block that calls the procedure I copied here,
I test if XLApp is already open and if not open it:
If IsNothing(XLApp) Then
XLApp = New XL.Application
End If
I hope this is what you need.
Siv
"Armin Zingler" <az*******@freenet.dewrote in message
news:uQ**************@TK2MSFTNGP05.phx.gbl..."Siv" <g@removethistextsivill.comschrieb>I don''t get a) why this is classed as late binding?
Without seeing a variable declaration, it''s impossible to see if it''s
late bound execution.
>and b) what I do
to stop it other than turn off option strict which I don''t want to
do.
1. Project -Add reference -COM tab -Add "Microsoft Excel x.y Object
Library"
2. Declare variables, for example, "As Excel.Application"
Then you are bound to the referenced Excel version on the target
machine.
Armin
Armin,
Vars as follows:
In the procedure that the code was taken from:
Dim n as integer = 0
Dim r as integer = 0
The XLApp var is declared at the top of the class as follows:
Private XLApp As XL.Application
At the start of the processing block that calls the procedure I copied here,
I test if XLApp is already open and if not open it:
If IsNothing(XLApp) Then
XLApp = New XL.Application
End If
I hope this is what you need.
Siv
"Armin Zingler" <az*******@freenet.dewrote in message
news:uQ**************@TK2MSFTNGP05.phx.gbl..."Siv" <g@removethistextsivill.comschrieb>I don''t get a) why this is classed as late binding?
Without seeing a variable declaration, it''s impossible to see if it''s
late bound execution.
>and b) what I do
to stop it other than turn off option strict which I don''t want to
do.
1. Project -Add reference -COM tab -Add "Microsoft Excel x.y Object
Library"
2. Declare variables, for example, "As Excel.Application"
Then you are bound to the referenced Excel version on the target
machine.
Armin
这篇关于晚期约束问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!