General discussion

Locked

VB6 ToolTipText

By stokecity ·
How do I produce a "wrap round" in the text input
for the ToolTipText property. Would like to produce a "box" of text not one complete line of text.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by tknilans In reply to VB6 ToolTipText

You may want to try the carriage return vbCr preceeded and followed by ampersand. I've never tried using in this context, but it may work. An example would be:

object.TooltipText = "This is the first line " & vbCr & "and this is the second line."

Collapse -

by stokecity In reply to

object.TooltipText = "This is the first line " & vbCr & "and this is the second line." gives "This is the first line " & vbCr & "and this is the second line." as a display.

Collapse -

by harun In reply to VB6 ToolTipText

This is a simple code to wrap a long string into seperate lines without spliting in the middle of a word.

You will need 1 command button and 3 textboxes to test the code.

Dim Found As Integer

If Len(Text1.Text) < 21 Then
Text2.Text = Text1.Text
Else
Found = InStrRev(Text1.Text, " ", 20)
Text2.Text = Mid(Text1.Text, 1, Val(Found))
Text3.Text = Mid(Text1.Text, Val(Found) + 1)
End If

Collapse -

by harun In reply to

Or
The code allows the programmer to define the number of characters each line will display and then inserts a Chr(13). Take a look it could be useful
'---------------------------------------------
'Me.txtMsg is the text box to print.
'TempMsg is the string that I build the printable message
'SelStart is the SelStart property of the text box - assigning it directly did not work
'75 is the number of characters that I needed on a line.

Dim TempMsg As String
Dim SelectLength, SelectStart, Trapper As Integer
If Len(Me.txtMsg.Text) < 75 Then
TempMsg = Me.txtMsg.Text
Else
SelectStart = 0
SelectLength = 75
Do While Len(Me.txtMsg.Text) > 0
Clipboard.Clear
If Len(Me.txtMsg.Text) < 75 Then
Me.txtMsg.SelLength = Len(Me.txtMsg.Text)
Else
Me.txtMsg.SelLength = 75
End If

Trapper = InStrRev(Me.txtMsg.SelText, Chr(32), -1, vbBinaryCompare)
If Trapper = 0 Then
Me.txtMsg.SelLength = Len(Me.txtMsg.Text)
Else
Me.txtMsg.SelLength = Trapper
End If

TempMsg = TempMsg & Me.txtMsg.SelText & Chr(13)
MsgBox TempMsg
Me.txtMsg.SelText = ""
Me.txtMsg.SelStart = 0
Loop
End If

Back to Web Development Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums