Results 1 to 10 of 10

Thread: distance between two points

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    195

    distance between two points

    Hello and hi.
    i draw textbox in form1 and run it.
    i type " abc1234 " in textbox1 and result " abc1234 "

    but i type " abc1234 " textbox1 result " a b c 1 2 3 4 " only some distance between all text

    i not know code

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    195

    Re: distance between two points

    for example input of html using css
    letter-spacing: 1px;
    when i type in input some distance between all typing
    how can vb6 program

  3. #3
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,668

    Re: distance between two points

    Code:
    Set Me.Font = textbox1.Font
    Distance = Me.TextWidth(textbox1.Text)

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    195

    Re: distance between two points

    for example input of html using css
    letter-spacing: 1px;
    when i type in input some distance between all typing
    how can vb6 program

  5. #5
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    958

    Re: distance between two points

    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.

  6. #6
    Addicted Member
    Join Date
    Jun 2018
    Posts
    189

    Re: distance between two points

    Quote Originally Posted by kako0000000 View Post
    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.)

    Name:  t1.png
Views: 279
Size:  10.1 KB

    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
    Attached Files Attached Files

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    195

    Re: distance between two points

    Thanks
    u write
    but not include space only distance character

  8. #8
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,734

    Re: distance between two points

    I believe it's called kerning.
    Don't know whether this is possible in a textbox, maybe a RichTextBox

  9. #9
    Addicted Member
    Join Date
    Jun 2018
    Posts
    189

    Re: distance between two points

    This might not be what you need, but just for an idea with a PictureBox.

    Name:  t4.png
Views: 312
Size:  11.1 KB

    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
    Some useful links:
    https://docs.microsoft.com/en-us/win...g--and-spacing
    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

  10. #10
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    462

    Re: distance between two points

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width