vb label

Posted on 2006-05-15
Last Modified: 2010-05-01

I have a text box that I use to gather data that goes into a database.

My program then displays that data in a label.

If I put a tab in the text box, when it displays in the label, it looks like a thick black line, kind of like the width of 2 or 3 lower case "L" s.

Is there any way around this?

Question by:jackjohnson44
    LVL 142

    Accepted Solution

    you have to replace the vbTab character by something else ( replace ( yourstring, vbtab, " ") ) , or use some other control (like richtextbox or textbox) instead of the label.
    note that you can LOCK the contents of the textbox, so the user can select, but not change the contents...
    LVL 6

    Assisted Solution

    Set the MultiLine property to True

    This will allow the box to accept Tabs
    You can replace it as mentioned by angelIII

    If you want the user to be able to type Tabs, then you will need to set all the TabStop properties to False when getting focus on that TextBox; e.g.

    Private Sub TextBox1_GotFocus()
    Call TabStops_Toggle(Me, False)
    End Sub

    Private Sub TextBox1_LostFocus()
    Call TabStops_Toggle(Me, True)
    End Sub

    Public Sub TabStops_Toggle(frmObject As Form, bEnabled As Boolean)
    ' Description : Toggle the TabStop Property within frmObject

    Dim C As Long
    Static bTabStops() As Boolean

    On Error Resume Next

    ReDim Preserve bTabStops(0 To frmObject.Controls.Count - 1) As Boolean

    For C = 0 To frmObject.Controls.Count - 1
        With frmObject.Controls(C)
            If Not bEnabled Then
                bTabStops(C) = .TabStop
                .TabStop = False
                .TabStop = bTabStops(C)
                bTabStops(C) = False
            End If
        End With
    Next C

    End Sub
    LVL 6

    Expert Comment

    Glad I could help...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now