【问题标题】:how to create tag text box like html tag (in ms access form)如何创建标签文本框,如 html 标签(在 ms 访问表单中)
【发布时间】:2019-11-12 11:27:11
【问题描述】:

如何在ms访问表单中创建标签文本框?

如下所示:

like this photo!!

【问题讨论】:

    标签: vba ms-access tags


    【解决方案1】:

    你可以使用一个类,像这样。它需要做一些工作,但这是我要开始的地方。未处于设计模式时无法添加控件,因此您期望的动态解决方案可能是不可能的。

    一个名为clsTagTextbox的类

    Option Explicit
    
    Private WithEvents tb As TextBox
    Private lbl As Label
    Private dicTags As Scripting.Dictionary
    
    Public Function Initialise(tbTagTextBoxElement As TextBox, _
                                lblLabelForTags As Label)
    
        Set tb = tbTagTextBoxElement
        Set lbl = lblLabelForTags
        Set dicTags = New Scripting.Dictionary
    
    End Function
    
    Private Sub tb_Exit(Cancel As Integer)
        If Not dicTags.Exists(tb.Text) Then
            dicTags.Add tb.Text, dicTags.Count
            lbl.Caption = Join(dicTags.Keys(), ",")
        End If
        tb.Text = ""
    End Sub
    

    然后在您的表单中,您有一个标签和一个文本框,我的是 txtTagBoxlblTags,我有代码

    Private c As clsTagTextbox
    
    Private Sub Form_Load()
        Set c = New clsTagTextbox
        c.Initialise Me.txtTagBox, Me.lblTags
    End Sub
    

    【讨论】:

    • 好的,它对我有用,我会留给你的。有没有关于错误的分享??
    • 您需要添加脚本运行时引用。谷歌如何添加参考。
    猜你喜欢
    • 2011-04-13
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多