Link to home
Start Free TrialLog in
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
ASKER CERTIFIED SOLUTION
Avatar of sazhagianambi
sazhagianambi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jchew
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