Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Flexible text box

micks_guptamicks_gupta Member Posts: 8
hi,

the problem is that i want to "access has a control which expands horizontally according to text in it to be more precise text box?"

is there any way by which a control can be designed so that if a text size is more than drawn size of textbox then control grows horizontally,access textbox grows vertically.

if anybody can give solution to this problem it will be great help.

Thanks

Micks

Comments

  • dokken2dokken2 Member Posts: 532
    : hi,
    :
    : the problem is that i want to "access has a control which expands horizontally according to text in it to be more precise text box?"
    :
    : is there any way by which a control can be designed so that if a text size is more than drawn size of textbox then control grows horizontally,access textbox grows vertically.
    :
    : if anybody can give solution to this problem it will be great help.
    :
    : Thanks
    :
    : Micks
    :
    :

    It is possible, this example assumes the default textbox font size of 8 points, change the CharPerInch constant for other fonts/sizes.

    [code]
    Private Sub text1_KeyUp(KeyCode As Integer, Shift As Integer)
    Const CharPerInch = 14 'assumes a font of 8 points
    Dim iLen As Integer, iInch As Double, lTwip As Double

    lTwip = Me.text1.Width 'get textbox width, in twips
    iInch = lTwip / 1440 'convert twips to inch
    iLen = Len(Me.text1.Text) 'length of chars in textbox

    'if num of chars exceed textbox charperinch, resize textbox
    If iLen > iInch * CharPerInch Then
    iInch = iLen / CharPerInch 'convert to inches
    lTwip = iInch * 1440 'convert to twips
    Me.text1.Width = CInt(lTwip) 'resize textbox width
    End If
    End Sub
    [/code]
Sign In or Register to comment.