这是我设计的一个例子,我创建这个来解释我遇到的问题.基本上我希望这段代码运行得比它快.在新的工作表上,单元格的每个循环都会快速启动,但如果让它运行到接近完成状态,然后再次运行,则每个单元格将达到100毫秒.在我的工作表中,我有16000个单元格,有很多这样的注释,每次代码运行时都会单独操作它们.在这个例子中,它们显然是完全相同的,但在实际应用中,每个都是不同的.
反正有没有让这个过程更快?
Option Explicit
Public Declare PtrSafe Function GetTickCount Lib "kernel32.dll" () As Long
Public Sub BreakTheCommentSystem()
Dim i As Integer
Dim t As Long
Dim Cell As Range
Dim dR As Range
Set dR = Range(Cells(2, 1), Cells(4000, 8))
Dim rStr As String
rStr = "ABCDEFG HIJK LMNOP QRS TUV WX YZ" & Chr(10)
For i = 1 To 5
rStr = rStr & rStr
Next i
For Each Cell In dR
t = GetTickCount
With Cell
If .Comment …Run Code Online (Sandbox Code Playgroud) 如果外键已经有一个引用但我想删除该引用,我该怎么做?
queryRecord.Single().OrderID = null;
Run Code Online (Sandbox Code Playgroud)
引发此ForeignKeyReferenceAlreadyHasValueException,我知道您必须将其设置为实体,但是如何将其设置为空实体?
我试过了
Order nullOrder = new Order();
queryRecord.Single().Orders = nullOrder.OrderID;
Run Code Online (Sandbox Code Playgroud)
但这也会引发相同的ForeignKeyReferenceAlreadyHasValueException
那么,如何将该字段设为空?
我想从Code Behind获取ControlToValidate属性,这是我的aspx.
<asp:CustomValidator runat="server" ID="custtxtTest" OnServerValidate="custtxtTest_ServerValidate" ControlToValidate="txtTest" ForeColor="Red" Text="*" />
Run Code Online (Sandbox Code Playgroud)
在我的代码后面我想获取属性"ControlToValidate",但这似乎不是源的有效属性:
protected void custtxtTest_ServerValidate(object source, ServerValidateEventArgs args)
{
string test = source.ControlToValidate;
}
Run Code Online (Sandbox Code Playgroud)
我检查了Asp.Net自定义验证器:如何在ClientValidationFunction上获取'controlToValidate'属性?但这只适用于客户端功能,而不是后面的代码.