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.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


str=<Assign the String which having Tabs>

Replace(str, vbTab, "    ")

This Command Replace the Tab Space as 4 BlankSpace.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jchewAuthor Commented:
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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.