首页 \ 问答 \ 我使用vba搜索功能时运行时错误1004(run time error 1004 when I use vba search function)

我使用vba搜索功能时运行时错误1004(run time error 1004 when I use vba search function)

我正在练习一些功能

当我在下面运行它返回运行时错误1004应用程序定义或对象定义的错误。

Public Sub se()
        a = 2
        While a < 6
            c = WorksheetFunction.IfError(WorksheetFunction.Search("1", "ella"), 100)
            MsgBox c
            a = a + 1
        Wend
End Sub

I'm practicing some function

when I run below it returns run-time error 1004 application-defined or object-defined error.

Public Sub se()
        a = 2
        While a < 6
            c = WorksheetFunction.IfError(WorksheetFunction.Search("1", "ella"), 100)
            MsgBox c
            a = a + 1
        Wend
End Sub

原文:https://stackoverflow.com/questions/27729134
更新时间:2022-11-21 12:11

最满意答案

就个人而言,我认为这不是测试中最困难的部分。 通过反思可以做到这一点,但这并不能使测试成为可能。

困难的部分是弄清楚所有可能的输入,“快乐的路径”和错误的情况,确保异常在应该发生时抛出等等。

你的Java Bean应该实现equals和hashCode。 我更担心测试来检查等价合约:空等于,反身,对称,传递,而不是等于。 这些都不是微不足道的。

吸气剂和吸附剂是你问题最少的。 当人们谈论70%或更高的代码覆盖率标准时,他们经常说可以忽略getter和setter。


Personally, I don't think that's the hardest part of testing. It'd be possible to do via reflection, but that's not what makes testing worthwhile.

The hard part is figuring out all the possible inputs, for "happy path" and erroneous situations, making sure that exceptions are thrown when they should be, etc.

Your Java Bean should be implementing equals and hashCode. I'd worry more about tests to check the equals contract: null equals, reflexive, symmetric, transitive, and not equals. Those aren't trivial.

Getters and setters are the least of your problems. When people talk about code coverage standards of 70% or better they often say that getters and setters can be left out.

相关问答

更多
  • JavaBean和class的区别:JavaBean只是比class多一些限制条件,其他无区别。 JavaBean实质也是一个类,这个类遵循: 1. 类必须是具体的和公共的。 2. 具有无参数的构造器。 3. 通过提供符合一致性设计模式的公共方法将内部域暴露成员属性(即getters和setters)。 4. 实现java.io.Serializable接口(这个目前是默认实现的,不需要特殊申明)。 例如以下为一个简单的JavaBean: package com.test; import java.lang ...
  • PO(persistant object) 持久对象 在o/r映射的时候出现的概念,如果没有o/r映射,没有这个概念存在了。通常对应数据模型(数据库),本身还有部分业务逻辑的处理。可以看成是与数据库中的表相映射的java对象。最简单的PO就是对应数据库中某个表中的一条记录,多个记录可以用PO的集合。PO中应该不包含任何对数据库的操作。 VO(value object) 值对象 通常用于业务层之间的数据传递,和PO一样也是仅仅包含数据而已。但应是抽象出的业务对象,可以和表对应,也可以不,这根据业务的需要. T ...
  • 只有一个“randomBean”,因为默认范围是“singleton” 。(要在每次需要时强制Spring生成一个新的bean实例,你应该将bean的scope属性声明为原型) 独生子 这将bean定义范围限定为每个Spring IoC容器的单个实例(默认)。 原型 这将单个bean定义范围限定为具有任意数量的对象实例。 Spring保证方法randomBean()将返回与注入AnotherBean的引用相同的引用。使用代理 。 为了生成代理,Spring使用名为CGLIB的第三方库。 Spring通过生成 ...
  • 就个人而言,我认为这不是测试中最困难的部分。 通过反思可以做到这一点,但这并不能使测试成为可能。 困难的部分是弄清楚所有可能的输入,“快乐的路径”和错误的情况,确保异常在应该发生时抛出等等。 你的Java Bean应该实现equals和hashCode。 我更担心测试来检查等价合约:空等于,反身,对称,传递,而不是等于。 这些都不是微不足道的。 吸气剂和吸附剂是你问题最少的。 当人们谈论70%或更高的代码覆盖率标准时,他们经常说可以忽略getter和setter。 Personally, I don't t ...
  • ---
  • 必须写在VUE而不是MODEL(BEAN) 我想你想使用MVC架构在jsp页面中显示你的列表,方法是: 1 /添加一个返回bean中列表的函数(Model) 2 /一个servlet,它实例化这个bean并调用这个函数并在请求中设置这个列表(控制器) 3 / jsp页面显示列表(查看) 这是一个例子:1 / Bean: 添加此功能: public List loadList() { List Mylist = new ...
  • 用@Configuration替换@Component ,它表示一个类声明一个或多个@Bean方法,并且可以由Spring容器处理,以在运行时为这些bean生成bean定义和服务请求。 @Configuration public class FactoryMethodComponent { private static int i; @Bean @Qualifier("public") public TestBean publicInstance() { return new TestB ...
  • 首先,如果您开始使用ApplicationContext或BeanFactory获取bean,一般来说,这样做是错误的(至少在使用Spring开发应用程序时)。 在方法上使用@Bean时,有效地使它成为这些bean的工厂方法,可以使用0个或更多方法参数。 (这也在参考指南中解释)。 参数是根据上下文解决的,并且会注入bean(如果找不到则会失败)。 因此,在您的情况下,您可以简单地添加JedisConnnectionFactory (或者可能是ConnectionFactory接口)作为eventTrans ...
  • 出现问题是因为 PropertyEditorRegistrySupport.class.getClassLoader() 是null 。 根据JavaDoc,如果类引导类加载器而不是系统类加载器加载了PropertyEditorRegistrySupport类,则会发生这种情况: 某些实现可能使用null来表示引导类加载器。 如果此类由引导类加载器加载,则此方法将在此类实现中返回null。 也许你的Spring库是在认可的类路径上? The problem occurs because PropertyE ...
  • 你可以看看Commons Beanutils,它有一大堆的方法来填充bean(包括嵌套的bean): http://commons.apache.org/beanutils/ 该方法,特别是你想要看的是在BeanUtilsBean中填充: public void populate(Object bean, Map properties) 更多信息在这里: http://commons.apache.org/beanutils/api/org/apache/comm ...
  • Spring中单例如何处理的一点是单例中没有代码限制它被调用的方式,它只是一个POJO。 Spring负责确保每个人都获得相同的实例。 这意味着如果你想为它编写一个单元测试,你的测试根本不需要使用Spring,测试可以像任何其他POJO一样实例化单例作为测试设置过程的一部分,并且测试代码可以插入mocks为其依赖。 这是单例执行单例的代码,这使得很难测试,Spring不再是问题。 The point of how singletons are handled in Spring is that there ...
  • 相关文章

    更多
  • The Log: What every software engineer should know about real-time data's unifying abstraction
  • error C2668: 'M' : ambiguous call to overloaded function
  • Riak Search
  • Realtime Search: Solr vs Elasticsearch
  • Solr: a custom Search RequestHandler
  • Real-Time Rendering 笔记 --- 1-4章
  • elastic search,又一个基于lucene的nosql好项目
  • 使用hibernate search和solr简化企业级搜索
  • Faceted search
  • Bentley.STAAD.RCDC.V8i.04.01.01.03 1CD
  • 最新问答

    更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)