问题标签 [byval]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
124 浏览

c# - 将 vb.net 转换为 c#- 优化参数传递

我想将一个 vb.net 应用程序移动到 c#。vb.net 应用程序有数千个应该是 byval 的 byref 参数。有人知道自动检查每个参数传递方法是否可以安全更改的方法吗?

0 投票
3 回答
818 浏览

vb.net - 使用 ByRef 和 ByVal

我对编程很陌生,有人告诉我应该使用 ByRef 和 ByVal 传递东西,但是当我这样做时,我收到一条错误消息:

我开始我的子:

0 投票
1 回答
52 浏览

string - 在没有指令的情况下将术语添加到字符串中

我有一个为当前用户设置变量的函数。变量名称以模块名称为前缀——基本上,应用程序的设置方式,Client 是一个类,Server 是一个类,Agency 是一个类等等。这是一种尝试创建一个系统,通过该系统,我们可以通过 200 多台服务器,通过尽可能少的点击并使用其数据库中的实时数据,找到有关客户或其网站的任何关键信息。

功能如下:

现在在第 5 行,它是第一次输出,只有“ID”作为变量名输出。但是 2 行后,名称设置为“Module.<module-name>.ID”(例如 Module.Server.ID。2 行之后,在 prepend 语句之后(其作用与 do 相同varName = "something" & varName),它输出something + "Module.<module-name>.ID".实际上,在这种情况下,它输出"Module.Server.Module.Server.ID"。请注意,如果我取出任何东西,它会从第一个 Module.Server 中取出,而不是第二个。有谁知道是什么原因造成的?看起来好像是 Module.Server 。服务器被添加到第 5 行和第 7 行之间的变量名称之前,但唯一的一行是 if 语句。提前致谢。

0 投票
0 回答
126 浏览

vba - VBA ByRef 参数的作用不同,无论是否通过括号传递

仅关于在 vba 中传递参数,如果参数在括号中传递而不是使用 ':=' 明确说明它们,ByRef 的行为似乎有所不同,例如:

第一个 MessageBox 将显示 123,而第二个将显示 321。我找不到任何地方解释为什么在括号中传递参数或使用 ':=" 时存在差异。有人知道为什么吗?

0 投票
1 回答
1851 浏览

excel - 按 Val 更改,目标范围未被识别

大家好,当我使用从模块运行的上述代码时,它会触发工作表中写入的 val 更改

现在,代码的 Cells 部分将四个单元格的块复制到第 12 列,一直到第 15 列,但更改 val 没有将第 15 列识别为具有更改的值。但是,当我将目标列更改为 11 时,

整个单元格块的值都会更改,因此进行了四个目标更改。

谢谢。

0 投票
2 回答
2435 浏览

excel - 按 val 目标更改为范围以忽略空白和 0 值单元格

我上面的代码运行良好,除了我试图添加粗体代码以忽略任何空白单元格(也可以是忽略 0 值单元格的选项,但不是必需的)。

0 投票
1 回答
3298 浏览

vb.net - 将值从 BackgroundWorker DoWork 传递到 BackgroundWorker Completed

如何将值从BackgroundWorker DoWorkto传递BackgroundWorker Completed?由于BackgroundWorker Completed不被调用,因此BackgroundWorker DoWork我不确定如何执行此操作,除非声明一个public variable. 本质上,我想BackgroundWorker Completed通过ByVal来自BackgroundWorker DoWork.

0 投票
1 回答
2075 浏览

vb.net - 错误:[表达式预期] 使用 ByVal 修饰符

我希望能得到您的帮助,因为我在使用 VB.net 的项目中遇到错误。我在使用 ByVal 修饰符时出错。7个错误都说“预期表达”。

我在第 97、103、103、112、112、146 和 146 行得到错误。总共 7 个错误。

他们来了:

97:

103:

112:

146:

这是完整的代码:

0 投票
1 回答
533 浏览

excel - vbval 与公共变量

在 VBA 中,我通常将共享变量定义为 Public,而不是通过 byVal 或 byRef 构建引用。最常见的是,我调用一个子程序或函数来为所述变量建立一个值。有人可以向我解释使用 byVal/byRef 与简单地创建公共变量的好处吗?

0 投票
1 回答
210 浏览

ajax - using ByRef over ByVal to hit a database

I'm using an ajax call to hit a database to load a drop down. Now, this is something we're going to be doing a lot where I work now that someone's figured out how to do it.

My supervisor has asked me to try and make my ajax call one that I can easily use for multiple pages and such without having to redo the code for each new page. My code:

Controller

JQuery

Now, I don't know VB.NET. In fact, a coworker helped me with the controller, and he's not here to assist further in this matter.

My question, posed by my supervisor, is how can we make this work?

If the ByVal in the controller class is changed to a ByRef, can we pass something in for the data: line in the ajax call so that this code can be reused and not rewritten?

Any help or clarification will be greatly appreciated.