As Eduardo- was explaining, the Width is a function of the selected font and font size used.
So it may vary. The Textbox does NOT have a way to compute the Font Width.
However the form does. It is .TextWidth and .TextHeight.
SO by putting 1 character only into the Textbox) you can determine the Font Width for that
particular font and size. There is NO spacing between individual characters, just
white space that is part of the width of any single character in a font.
Depending whether the font is a Fixed Type, True Type, etc. the rendering of them is a
complicated (lot of things to consider) process.
Search for True Type font and get ready to learn a lot.
Last edited by vb6forever; Aug 26th, 2018 at 09:40 PM.
for example input of html using css
letter-spacing: 1px;
when i type in input some distance between all typing
how can vb6 program
Hi,
It's not very clear what you are exactly asking.
Do you expect something like below?
(Check the attached sample also for your easiness.)
Code:
Option Explicit
Private Sub Text1_Change()
Text2.Text = GetTxtWithSpaces(Text1)
End Sub
Private Function GetTxtWithSpaces(tbx As TextBox) As String
Dim i As Integer, txt As String
With tbx
For i = 1 To Len(.Text)
txt = txt & Mid$(.Text, i, 1) & " "
Next
End With
GetTxtWithSpaces = RTrim$(txt)
End Function
This might not be what you need, but just for an idea with a PictureBox.
Code:
Option Explicit
Private Sub Text1_Change()
Call SetTracking(Text1.Text, 40)
End Sub
Private Sub SetTracking(txt As String, charspace As Byte)
Dim Char As String
Dim i As Byte
With Picture1
.Cls
.FontSize = Text1.FontSize
.FontName = Text1.Font
For i = 1 To Len(txt)
Char = Mid(txt, i, 1)
Picture1.Print Char;
.CurrentX = .CurrentX + charspace
Next
End With
End Sub
This is a unicode vs ascii problem. VB6 is taking the leading 0 and converting it into a space character instead of ignoring it. This is why every letter is preceded by a blank space.
Change your IME or check its settings. You may have an option to ignore the leading space. There is also a setting for "non-unicode programs" you can search for and change to your preferred language.
Last edited by DllHell; Aug 27th, 2018 at 10:35 AM.