- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些简单的代码,我明白它的作用但不知道为什么。我有一个 Sub
,它调用另一个名为 CheckIfNothing(oList)
的 Sub
。 oList
是一个 List(Of String)
。 Sub
CheckIfNothing
检查每个 String
如果它是 Nothing
它将成为 ""
。这是代码:
Public Function GiveList(oList As List(Of String))
CheckIfNothing(oList)
Return oList
End Function
Public Sub CheckIfNothing(oList As List(Of String))
For Each s As String In oList
If s Is Nothing Then
s = ""
End If
Next
End Sub
所以在 GiveList
中,我调用了 CheckIfNothing
并且我没有从 CheckIfNothing
返回任何东西,而且 oList
在 GiveList
中没有 Strings
是 Nothing
。
我一直认为您必须返回您在被调用函数中更改的值,并在您调用该函数的子程序中再次设置值,如下所示:oList = CheckIfNothing(oList)
。 CheckIfNothing
在这种情况下将是一个函数。
为什么这不是必需的,这仅在 VB.NET 中还是在 C# 中也是如此?
最佳答案
也许这有助于解释您的问题。它来自关于 Visaul Basic 2013 的 MSDN。
将参数传递给过程时,请注意几个相互影响的不同区别:
•底层编程元素是可修改的还是不可修改的
•参数本身是可修改的还是不可修改的
•参数是按值还是按引用传递
•参数数据类型是值类型还是引用类型
有关详细信息,请参阅 Differences Between Modifiable and Nonmodifiable Arguments (Visual Basic)和 Differences Between Passing an Argument By Value and By Reference (Visual Basic) .
此代码是一个示例,说明如何在参数周围使用 () 来保护参数不被更改。
Sub setNewString(ByRef inString As String)
inString = "This is a new value for the inString argument."
MsgBox(inString)
End Sub
Dim str As String = "Cannot be replaced if passed ByVal"
' The following call passes str ByVal even though it is declared ByRef.
Call setNewString((str))
' The parentheses around str protect it from change.
MsgBox(str)
' The following call allows str to be passed ByRef as declared.
Call setNewString(str)
' Variable str is not protected from change.
MsgBox(str)
Passing Arguments by Value and by Reference (Visual Basic) 2013
关于vb.net - Sub 如何更新它的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22488983/
我在产品类别和子类别网站上工作,可以创建的子类别数量是无限的,这意味着我们可以自己拥有子类别的子类别。一切正常,我只是有一个问题:假设“PRODUCT 1”属于“SUB SUB CATEGORY 1”
我正在学习OCaml,并在代码2022的到来中努力工作。。但似乎读取input.txt文件会导致一些问题。。我收到了这个奇怪的错误,它来自于函数分数。尤其是那个叫得分手HD的表达。不过,当我手动将LI
我有一个奇怪的行为(对于 Python 程序员)子例程,它简化如下: use strict; use Data::Dumper; sub a { my @x; sub b { push @x,
在此页上 http://bit.ly/T3yJIH , drupal 的 Nice Menu 模块不能正确显示子子菜单。如果转到菜单中的第一项,然后转到子菜单中的第一项,就可以看到它。 (Facili
我需要在我的站点内创建一个子结构,我在其中拥有: 实际上我是通过 Javascript 来完成的(伪代码):SUB_Content.height = ParentDiv.height - Sub_He
我有一个与子菜单一起使用的 CSS 手册。我想知道如何向它添加子子菜单。例如,我将鼠标悬停在主菜单项上并弹出子菜单,然后我将鼠标悬停在子菜单项上并弹出另一个子菜单。这是我现在使用的 JS Fiddle
我有一个关于 navmenu 的问题我不能选择导航菜单的 sub sub ul,如果我会做什么它会影响 3.ul。这是一个 wordpress 菜单我没有机会使用类或菜单的 ID。提前感谢您的帮助。
我创建了一个带有 2 级子菜单的简单导航。我正在寻找“sub sub”选项以显示在其父项的右侧而不是下方。对于 CSS 的任何帮助,我将不胜感激。下面是 html 和 css 以及 JS fiddle
我对 VBA、这个论坛和编程很陌生。我有一个工作表,我已经设法根据我的要求谷歌并调整某些代码行。 我的问题是我总共有三个潜艇,必须逐步运行每个 VBA 脚本。我希望将所有三个 VBA 脚本合二为一。
我使用 sub 调用作为另一个 sub 的参数。示例代码: test(isInString(), 'second parameter', 'third parameter'); sub test {
我想使用 HTML ui->FresBox->setText("fres"); 但它在 QCheckbox 中不起作用。如果您使用标签,它会很好用。有什么不同以及如何在 QCheckbox 中使用 H
我没有遇到这个问题,但在处理相关问题时想到了这个问题。让我们: logging = 'something' # bad naming decision import logging as lg
我正在查看 Redis pubsub,消费者是 2-4 节点自动缩放组的一部分(HA 原因) 也许我遗漏了一些明显的东西,但是 Redis pubsub 中是否有某种机制可以管理订阅者/消费者收到的重
对你们来说应该是一个快速和简单的,为什么这不起作用? 代码限制用户只能在文本框中输入文本。 它工作正常,但我有大约 50 个文本框,所以会更干净,更容易调用。 但是,这样做,限制不再起作用 Priva
(编辑)TL; DR :我的问题是,尽管Win32 API定义的是真实的整数常量(如平台SDK header 中一样),而Win32 Perl包装器将它们定义为subs。从而引起一线解析的误解。 在单
我有一个使用 Jersey 实现 REST API 的 Web 应用程序。 Web 容器 id Tomcat 以下是 API 的摘要: /rest/patients 获取患者元数据列表。 /rest/
我与 Czech 一起工作Python 3.4 中的重音文本。 调用 re.sub()用正则表达式对重音句子进行替换效果很好,但使用用 re.compile() 编译的正则表达式然后调用regex.s
对于我的一个新项目,我必须创建一个包含主类别、子类别和子子类别的类别页面。例如; 互联网 互联网 > 发展 互联网 > 开发 > 移动应用 在此类别中,您可以找到有关这些内容的网站。我必须为每个网站提
表1 - 客户数据 c_id(整数) 名称(varchar) 表2 - account_data a_id(整数) c_id (int) -> 使用customer_data。c_id plan_id
我有一些位图文件(jpeg、png、...),我想编写一个 C++ 程序,将这些位图文件连接到 pes 流(mpeg-2 格式),然后创建一个子文件(.sub/. idx:vobsub 字幕文件)。
我是一名优秀的程序员,十分优秀!