Avatar of jchew
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.

Thanks
Visual Basic Classic

Avatar of undefined
Last Comment
jchew

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
sazhagianambi

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
or
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
jchew

ASKER
hi Nambi,

your answer is not exactly what i wanted... then after scanning EE further, found the solution at
https://www.experts-exchange.com/questions/20230663/Set-TabWidth-Of-Richtextbox.html


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

Private Const EM_SETTABSTOPS = &HCB


' 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
   Next

   '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.

regards
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