一个非常奇怪的问题:关于label控件.无法改变label.caption的值.
比如我有两个窗体
form1 上有 command1 ,command2
form2 上有 label1 任何属性都不改,我写这样一些简单的代码,Private Sub Command1_Click()
Form2.Show 1 '显示窗体2
End SubPrivate Sub Command2_Click()
Form2.Label1.Caption = "12" 把窗体2上的label1.caption改成"12"
End Sub按理说我先点击command2,Form2.Label1.Caption应该变成12了,点击command1,的确如此,
关掉form2,可是在点击command1,再次打开form2,这是Form2.Label1.Caption又变回默认值,也就是
label,这是怎么回事?难道据没有办法让Form2.Label1.Caption一直是12了吗?实在是奇怪,请大家告知.
比如我有两个窗体
form1 上有 command1 ,command2
form2 上有 label1 任何属性都不改,我写这样一些简单的代码,Private Sub Command1_Click()
Form2.Show 1 '显示窗体2
End SubPrivate Sub Command2_Click()
Form2.Label1.Caption = "12" 把窗体2上的label1.caption改成"12"
End Sub按理说我先点击command2,Form2.Label1.Caption应该变成12了,点击command1,的确如此,
关掉form2,可是在点击command1,再次打开form2,这是Form2.Label1.Caption又变回默认值,也就是
label,这是怎么回事?难道据没有办法让Form2.Label1.Caption一直是12了吗?实在是奇怪,请大家告知.
当再次加载时(打开窗体),当然会是初始的设置了,即Label.caption的值当然是初始的值拉。
but hide form2
Private Sub Form_Load()
Label1.Caption = "12" 把窗体2上的label1.caption改成"12"
End Sub
您先点击command2时form2已经被加载了,form2.show 1 仅起到了form2.visible=True的作用,所以显示“12”。
根据具体情况有多种方法可实现您的要求,如不行请说明。
您先点击command2时,相当于执行了以下3条语句:
form2.show
form2.label1="12"
form2.hide
form2已经被加载了,这时再点击command1时 form2.show 1 仅起到了form2.visible=True的作用,所以显示“12”。
根据具体情况有多种方法可实现您的要求,如不行请说明。
sub form2_load()
form2.label1.caption=strLableCaptionend subform1的
sub Commad1_click ()
strLableCaption="ff"
form2.show
end sub