Avatar of jchew
 asked on

changing VB textbox's tabwidth

hi all,

in VB, by default, the tab width is 8 characters.  how can i change that to 4 characters?

please advice.

Visual Basic Classic

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

hi Nambi,

your answer is not exactly what i wanted... then after scanning EE further, found the solution at

manage to adapt that solution to mine, so i added the following codes :

Private Declare Function SendMessageArray Lib "user32" Alias "SendMessageA" _
       (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long


' Set new tab stops (in dialog units)
' Note: Default tabs stops are every 32 dialog units
Sub SetTabStops(txtb As TextBox)
Const cMAX = 20
Const cSIZE = 16

   If txtb Is Nothing Then Exit Sub

   ' Can't seem to pass the ParamArray to SendMessage, so copy it to array of long
   ReDim a(cMAX) As Long

   Dim t As Long
   Dim tabcount As Long
   tabcount = cMAX + 1

   For t = 0 To cMAX
       a(t) = (t) * cSIZE

   'Clear any existing tabs.
   Call SendMessageArray(txtb.hWnd, EM_SETTABSTOPS, 0&, 0&)
   'Set the tabs.
   Call SendMessageArray(txtb.hWnd, EM_SETTABSTOPS, tabcount, a(0))

End Sub

since i can't award the points to nazdor (the original poster) and i also can't award the points to myself :)

so i'll award them to you.

thanks for your effort.

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy