简体   繁体   English

Excel 的问题 - 第三方是否篡改了我的计算机?

[英]Problems with Excel - Is a third party tampering with my computer?

The following codes did not work for me, today.今天,以下代码对我不起作用。 I think somebody is tampering with my computer.我认为有人在篡改我的电脑。 I wonder, how this could be duplicated, or is there an error with my code:我想知道,这怎么可能被复制,或者我的代码有错误:

'number of rows for a certain column:
dim c as integer
c = WorksheetFunction.counta(columns("A:A"))
'get a value
c = range("A1")

Additional:额外的:
My code is a homework assignment, "Monte Carlo Simulation".我的代码是家庭作业“蒙特卡罗模拟”。 It basically changes the costs of a list of items used to bake cookies and is using different types of distributions (uniform, normal, discrete) to do so.它基本上改变了用于烘焙饼干的项目列表的成本,并使用不同类型的分布(均匀、正态、离散)来做到这一点。 Excel exhausted its resources, because of an ill-formed loop with circular referencing - so the error message). Excel 耗尽了它的资源,因为循环引用的错误格式循环 - 所以错误消息)。 I restarted Excel repeatedly.我反复重启Excel。 Eventually, I used original codes, which were provided by the Professor, and step by step re-inserted functions and procedures I already had coded, in order to find out how I had caused the Excel error message with my coding efforts.最后,我使用了教授提供的原始代码,并一步一步地重新插入我已经编写好的函数和程序,以找出我在编码过程中是如何导致 Excel 错误消息的。 I ended up with 1000 of the "Monte-Carlo-Simulations" in 1 minute, rather than 30 minutes, observed before.我在 1 分钟内完成了 1000 个“蒙特卡罗模拟”,而不是之前观察到的 30 分钟。 The codes I provided I consider basic, but I am not able to resolve the issue, even if I copy old codes into my VBA modules.我提供的代码我认为是基本的,但我无法解决问题,即使我将旧代码复制到我的 VBA 模块中。 How could I avoid that an ie third party can tamper with my computer?我怎样才能避免 ie 第三方篡改我的计算机?

Added on July 20, 2021添加于 2021 年 7 月 20 日
This code uses the controls collection in order to obtain values of data on a form.此代码使用控件集合来获取表单上的数据值。 You need form with two text fields which should have ie have double value content.您需要具有两个文本字段的表单,它们应该具有双值内容。 So the controls collection is not working, since today.因此,从今天起,控件集合不起作用。

ie txtPerc1 and txt1txtPerc1txt1
and then the function will return a value along with the discrete distribution.然后该函数将返回一个值以及离散分布。
The controls lines are commented out because I receive the error "sub or function not defined. I checked the name of the field and it was okay.控件行被注释掉,因为我收到错误“子或函数未定义。我检查了字段的名称,没问题。

'sample call:
'discreteDistribtion("Hallo", 3)
' So I have six fields named:
' halloPerc1, halloPerc2, halloPerc3 and hallo1, hallo2, and hallo3
' the function takes here "hallo" and generates the names Hallo1, Hallo2, Hallo3 and halloPerc1, halloPerc2, and halloPerc3
' the function takes the value of hallo1, hallo2, or hallo3, each of these fields having doubles as content.
' According to the logic, hallo1, hallo2 or hallo3 values are returned!
' The code does not work on my computer, when I uncomment the controls code, it worked the weeks before.

Function discreteDistribution(strCtrl As String, iEnd As Integer, Optional iStart As Integer = 1)
    Dim i As Integer, sum As Double, r As Double, strTemp As String
    sum = 0
    r = Rnd
    discreteDistribution = 0
    For i = iStart To iEnd
        strTemp = strCtrl & "Perc" & i
        ''''''sum = sum + Controls(strTemp).Value
        If r < sum Then
            strTemp = strCtrl & i
        ''''''    discreteDistribution = Controls(strTemp)
            Exit For
        End If
    Next i
End Function

I added a second userform to my work book on a separate sheet and the following code is working:我在单独的工作表上向我的工作簿添加了第二个用户表单,并且以下代码正在运行:

Option Explicit

Dim i As Integer


Private Sub CommandButton1_Click()
    For i = 1 To 10
        Controls("TextBox" & i).Value = Cells(i + 1, 1).Value
    Next i
End Sub

Private Sub UserForm_Click()

End Sub

This code fills a bunch of textboxes with telephone numbers collected on a spread sheet.此代码用电子表格上收集的电话号码填充一堆文本框。 Still, I was not able to get my original code to work.尽管如此,我还是无法让我的原始代码工作。

The code, recognized as faulty by Excel, highlighting the location, for the error shown in the previous image:代码被 Excel 识别为错误,突出显示了上图中显示的错误的位置:

Though not the entire question is answered here, my today's problem is resolved.虽然这里没有回答整个问题,但我今天的问题已经解决了。 The controls collection is a property of the user form.控件集合是用户表单的一个属性。 So in order to call this collection from within a module, it needs to know the form it is related to.所以为了从模块内部调用这个集合,它需要知道它所关联的表单。 So rather than calling controls("Name of Control") = ... the call must be: form.controls("Name of Control") and then the code works.因此,而不是调用controls("Name of Control") = ...调用必须是: form.controls("Name of Control")然后代码工作。

Thank you to everybody who replied to my request for encouragement.感谢所有回复我的鼓励请求的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 两台计算机试图访问第三台计算机(服务器)中的excel文件进​​行写入。 方法问题 - Two computers trying to access a excel file in a third computer (server) to write. Problems with the method 如何在没有第三方工具的情况下将 .sql 文件转换为 .xlsx(excel) - how to convert .sql file to .xlsx(excel) without third party tools excel与vbscript一起使用第三方COM ADD-IN - excel with vbscript which is using third party COM ADD-IN 将第三方应用程序 (MS Excel) 与 SAP R/3 连接 - Connect a third-party application (MS Excel) with SAP R/3 使用带有 Excel JS 插件的第三方节点模块 - Using third-party node modules with Excel JS Add-In 将 XML Excel 电子表格转换为 PDF 的第三方工具 - third party tool to conver XML Excel spreadsheets into PDF Excel Power View 无法在我的计算机上运行 - Excel power view is not working on my computer Excel中的“ My.Computer.Clipboard”对象 - “My.Computer.Clipboard” object in Excel 是否有任何第三方工具可以将XML数据导入Excel? - Are there any third-party tools which allow importing XML data into Excel? 无需使用第三方dll / oledb / interop / sdk即可在C#中读取Excel文件 - Read excel files in C# without using third party dlls/oledb/interop/sdk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM