标题: [求助]如何实现单击标签使被单击的标签变色? [打印本页] 作者: ikon 时间: 2008-2-17 21:15 标题: [求助]如何实现单击标签使被单击的标签变色? [attach]28464[/attach]
借用一下论坛上的一个例子截图,
问题:如何实现单击标签使被单击的标签变色而其他不变色?(例如:单击"苹果"这个标签,只有这个标签变色,其他标签不变色,下面我写的报错)
[attach]28465[/attach]
Option Compare Database
Public ctl As Control
----------------------------------------------
Private Function LabelClick(LabCaption As String)
Select Case ctl.BackStyle
Case 0
ctl.BackStyle = 1
Case 1
ctl.BackStyle = 0
End Select
End Function
-----------------------------------------------
Private Sub Form_Load()
For Each ctl In Me.Controls
If ctl.ControlType = acLabel And ctl.Tag = "num" Then ctl.OnClick = "=LabelClick('" & ctl.Caption & "')"
Next
End Sub
[ 本帖最后由 ikon 于 2008-2-17 21:23 编辑 ]作者: t小宝 时间: 2008-2-17 23:19 标题: 帮你改一下 '----------------------------------------------
Function LabelClick(stName As String)
Select Case Me.Controls(stName).BackStyle
Case 0
Me.Controls(stName).BackStyle = 1
Case 1
Me.Controls(stName).BackStyle = 0
End Select
End Function
'-----------------------------------------------
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acLabel And ctl.Tag = "num" Then ctl."" & ctl.Name & """)"
Next
End Sub作者: ikon 时间: 2008-2-19 00:02
问题解决了,顶上去