Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VB.Net代码使用冒号分组缩进:_.net_Vb.net_Winforms_Groupbox - Fatal编程技术网

VB.Net代码使用冒号分组缩进:

VB.Net代码使用冒号分组缩进:,.net,vb.net,winforms,groupbox,.net,Vb.net,Winforms,Groupbox,因此,在我现在处理的代码中,我的前任在VB.Net表单中的组框的某些项之前编写了这些奇怪的冒号。看起来是这样的: myGroupBox.Text=“myGroupBox” myGroupBox.Bounds=新矩形(…) :firstGrpBxElement.Text=“First” :firstGrpBxElement.Bounds=新矩形(…) :scndGrpBxElement.Text=“秒” :scndGrpBxElement.Bounds=新矩形(…) :thirdGrpBxElem

因此,在我现在处理的代码中,我的前任在VB.Net表单中的组框的某些项之前编写了这些奇怪的冒号。看起来是这样的:

myGroupBox.Text=“myGroupBox”
myGroupBox.Bounds=新矩形(…)
:firstGrpBxElement.Text=“First”
:firstGrpBxElement.Bounds=新矩形(…)
:scndGrpBxElement.Text=“秒”
:scndGrpBxElement.Bounds=新矩形(…)
:thirdGrpBxElement.Text=“第三”
:thirdGrpBxElement.Bounds=新矩形(…)
myGroupBox.Height=thirdGrpBxElement.Bottom+Padding
。。。其中,
=新矩形(…)
表示正确的矩形。
只是为了让它更容易阅读(我想坐标在这种情况下并不重要)

这些冒号是什么意思?只是为了可读性,还是我应该使用它们? 因为到目前为止,在我理解它们的上下文中,一旦我手动将它们添加到代码中(我在中间添加了代码),它们似乎就会被IntelliSense删除

我在谷歌上找不到任何东西(可能是因为我不知道它们是怎么叫的),所以如果有任何帮助,我将不胜感激。
谢谢大家!

可以在VB.NET中使用冒号来组合同一行上的语句

例如,这是有效的:

Dim a = 1 : Dim b = 2

Dim a = 1
Dim b = 2
也许代码以前是这样使用的

If a = 1 Then b = 2 : c = 3
此“保存”If..End If块,因此与

If a = 1 Then
    b = 2
    c = 3
End If
假设您在那里的语句意味着第一个语句是空的,冒号是多余的,因此IntelliSense会删除它


无论如何,我都会避免这些连接,因为它们会大大降低可读性。

非常感谢!我想知道他们是什么意思,虽然我知道“在同一行上使用”——意思是,我不知道他们在这里是什么意思。然后我会取下它们,以确保它的一致性。