Vb.net 将变量传递到标签vb中
我目前正在创建一个国际象棋游戏a,以节省大量的Vb.net 将变量传递到标签vb中,vb.net,Vb.net,我目前正在创建一个国际象棋游戏a,以节省大量的if语句。我想知道是否有办法将x等变量插入下面的标签中: Label1.Text = "MyRedPawns()" 我希望它进入()中,类似于控制台所用的 编辑: 代码如下: For x = 1 To 4 If mouseclicklocation.X >= MyRedPawns(x).getposition.X And mouseclicklocation.X <= MyRedPawns(x).getposition.X + 80
if
语句。我想知道是否有办法将x
等变量插入下面的标签中:
Label1.Text = "MyRedPawns()"
我希望它进入()
中,类似于控制台所用的
编辑:
代码如下:
For x = 1 To 4
If mouseclicklocation.X >= MyRedPawns(x).getposition.X And mouseclicklocation.X <= MyRedPawns(x).getposition.X + 80 Then
If mouseclicklocation.Y >= MyRedPawns(x).getposition.Y And mouseclicklocation.Y <= MyRedPawns(x).getposition.Y + 80 Then
Label1.Text = "MyRedPawns( )"
Piecefound = True
End If
End If
Next x
x=1到4的
如果mouseclicklocation.X>=MyRedPawns(X).getposition.X和mouseclicklocation.X=MyRedPawns(X).getposition.Y和mouseclicklocation.Y问题不清楚。不过,我会试试看。我猜您希望将变量x
的值插入字符串中。您可以使用:
结果:MyRedPawns(4711)
请查看的备注部分,了解其工作原理。如果我们使用变量x=“Hello”将文本从x输入标签,我们将执行以下操作:
Label1.Text = x
我不确定MyRedPawns()实际做什么或返回什么,所以我可能是错的,但如果它返回一个字符串并接受一个参数,那么您应该能够执行以下操作:
Label1.Text = MyRedPawns(x)
您可以这样做:
Label1.Text = "MyRedPawns(" & x & ")"
这一点并不清楚。什么样的变量是x
,您希望得到什么样的结果?
Label1.Text = "MyRedPawns(" & x & ")"